﻿using M2Server.Mon;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using SystemModule;

namespace M2Server
{
    public partial class TPlayObject
    {
        /// <summary>
        /// 客户端查询包裹物品
        /// </summary>
        public unsafe void ClientQueryBagItems()
        {
            TStdItem Item;
            string sSENDMSG;
            TClientItem ClientItem = null;
            TOClientItem* OClientItem = null;
            TStdItem StdItem = null;
            TUserItem UserItem = null;
            string sUserItemName;
            if (m_boCanQueryBag) // 是否可以刷新包裹
            {
                return;
            }
            m_boCanQueryBag = true;
            try
            {
                if (m_nSoftVersionDateEx == 0)
                {
                    sSENDMSG = "";
                    if (this.m_ItemList.Count > 0)
                    {
                        for (int i = 0; i < this.m_ItemList.Count; i++)
                        {
                            UserItem = this.m_ItemList[i];
                            if (UserItem != null)
                            {
                                Item = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                if (Item != null)
                                {
                                    StdItem = Item;
                                    M2Share.ItemUnit.GetItemAddValue(UserItem, StdItem);
                                    M2Share.CopyStdItemToOStdItem(StdItem, &OClientItem->s);// 取自定义物品名称
                                    sUserItemName = "";
                                    if (UserItem.btValue[13] == 1)
                                    {
                                        sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                                    }
                                    if (sUserItemName != "")
                                    {
                                        HUtil32.StrToSByteArry(sUserItemName, OClientItem->s.Name, 14, ref OClientItem->s.NameLen);
                                    }
                                    OClientItem->Dura = UserItem.Dura;
                                    OClientItem->DuraMax = UserItem.DuraMax;
                                    OClientItem->MakeIndex = UserItem.MakeIndex;
                                    if (StdItem.StdMode == 50)
                                    {
                                        string stemp = HUtil32.SBytePtrToString(OClientItem->s.Name, 0, OClientItem->s.NameLen);//临时存放物品名称
                                        HUtil32.StrToSByteArry(stemp + "#" + (UserItem.Dura), OClientItem->s.Name, 14, ref OClientItem->s.NameLen);
                                    }
                                    sSENDMSG = sSENDMSG + EncryptUnit.EncodeBuffer(OClientItem, Marshal.SizeOf(typeof(TOClientItem))) + "/";
                                }
                            }
                        }
                    }
                    if (sSENDMSG != "")
                    {
                        this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_BAGITEMS, this.m_ActorsId, 0, 0, this.m_ItemList.Count, 0);
                        SendSocket(this.m_DefMsg, sSENDMSG);
                    }
                }
                else
                {
                    sSENDMSG = "";
                    if (this.m_ItemList.Count > 0)
                    {
                        for (int i = 0; i < this.m_ItemList.Count; i++)
                        {
                            UserItem = this.m_ItemList[i];
                            if (UserItem != null)
                            {
                                Item = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                if (Item != null)
                                {
                                    StdItem = Item;
                                    M2Share.ItemUnit.GetItemAddValue(UserItem, StdItem);
                                    ClientItem = new TClientItem();
                                    ClientItem.s = StdItem;
                                    sUserItemName = "";  // 取自定义物品名称
                                    if (UserItem.btValue[13] == 1)
                                    {
                                        sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                                    }
                                    if (UserItem.btValue[12] == 1) // 物品发光
                                    {
                                        ClientItem.s.Reserved1 = 1;
                                    }
                                    else
                                    {
                                        ClientItem.s.Reserved1 = 0;
                                    }
                                    if (sUserItemName != "")
                                    {
                                        ClientItem.s.Name = sUserItemName;
                                    }
                                    if ((StdItem.StdMode == 60) && (StdItem.Shape != 0))// 酒类,除烧酒外
                                    {
                                        if (UserItem.btValue[0] != 0)
                                        {
                                            ClientItem.s.AC = UserItem.btValue[0];// 酒的品质
                                        }
                                        if (UserItem.btValue[1] != 0)
                                        {
                                            ClientItem.s.MAC = UserItem.btValue[1];// 酒的酒精度
                                        }
                                    }
                                    if (StdItem.StdMode == 8) // 酿酒材料
                                    {
                                        if (UserItem.btValue[0] != 0)
                                        {
                                            ClientItem.s.AC = UserItem.btValue[0]; // 材料的品质
                                        }
                                    }
                                    ClientItem.Dura = UserItem.Dura;
                                    ClientItem.DuraMax = UserItem.DuraMax;
                                    ClientItem.MakeIndex = UserItem.MakeIndex;
                                    sSENDMSG = sSENDMSG + EncryptUnit.EncodeBuffer<TClientItem>(ClientItem) + "/";
                                }
                            }
                        }
                    }
                    if (sSENDMSG != "")
                    {
                        this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_BAGITEMS, this.m_ActorsId, 0, 0, this.m_ItemList.Count, 0);
                        SendSocket(this.m_DefMsg, sSENDMSG);
                    }
                    IsItem_51(1);// 发送聚灵珠的经验
                }
            }
            finally
            {
                m_boCanQueryBag = false;
            }
        }

        /// <summary>
        /// 解包物品
        /// </summary>
        /// <returns></returns>
        private string ClientUseItems_GetUnbindItemName(int nShape)
        {
            string result = "";
            TUnbindInfo UnbindInfo;
            if (M2Share.g_UnbindList.Count > 0)
            {
                for (int i = 0; i < M2Share.g_UnbindList.Count; i++)
                {
                    UnbindInfo = M2Share.g_UnbindList[i];
                    if (UnbindInfo.nUnbindCode == nShape)
                    {
                        result = UnbindInfo.sItemName;
                        break;
                    }
                }
            }
            return result;
        }

        public bool ClientUseItems_GetUnBindItems(string sItemName, int nCount)
        {
            bool result = false;
            TUserItem UserItem = null;
            if (nCount <= 0)
            {
                nCount = 1;
            }
            for (int i = 0; i < nCount; i++)
            {
                UserItem = new TUserItem();
                if (M2Share.UserEngine.CopyToUserItemFromName(sItemName, UserItem))
                {
                    this.m_ItemList.Add(UserItem);
                    if (this.m_btRaceServer == Grobal2.RC_PLAYOBJECT)
                    {
                        SendAddItem(UserItem);
                    }
                    result = true;
                }
                else
                {
                   UserItem=null;
                    break;
                }
            }
            return result;
        }

        public bool ClientUseItems_FoundUserItem(TUserItem Item)
        {
            bool result = false;
            TUserItem UserItem;
            if (this.m_ItemList.Count > 0)
            {
                for (int i = 0; i < this.m_ItemList.Count; i++)
                {
                    UserItem = this.m_ItemList[i];
                    if (UserItem == Item)
                    {
                        result = true;
                        break;
                    }
                }
            }
            return result;
        }

        /// <summary>
        /// 客户端使用物品
        /// </summary>    
        private void ClientUseItems(int nItemIdx, string sItemName)
        {
            int ItemCount;
            bool boEatOK;
            bool boSendUpDate;
            TUserItem UserItem = null;
            TStdItem StdItem = null;
            TUserItem UserItem34 = null;
            string sMapName = string.Empty;
            int nCurrX = 0;
            int nCurrY = 0;
            int dwExp;
            m_boCanQueryBag = true;// 使用物品时,不能刷新包裹
            try
            {
                boEatOK = false;
                boSendUpDate = false;
                if (m_boCanUseItem)// 能使用物品
                {
                    if (!this.m_boDeath)
                    {
                        for (int i = this.m_ItemList.Count - 1; i >= 0; i--)
                        {
                            if (this.m_ItemList.Count <= 0)
                            {
                                break;
                            }
                            UserItem = this.m_ItemList[i];
                            if (UserItem == null)
                            {
                                continue;
                            }
                            if ((UserItem != null) && (UserItem.MakeIndex == nItemIdx))
                            {
                                UserItem34 = UserItem;
                                StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                if (StdItem != null)
                                {
                                    if (!this.m_PEnvir.AllowStdItems(UserItem.wIndex))// 检查地图是否禁用此物品
                                    {
                                        this.SysMsg(string.Format(GameMsgDef.g_sCanotMapUseItemMsg, StdItem.Name), TMsgColor.c_Red, TMsgType.t_Hint);
                                        break;
                                    }
                                    switch (StdItem.StdMode)
                                    {
                                        case 0:
                                        case 1:
                                        case 3:// 药
                                            if (EatItems(StdItem))
                                            {
                                                if (UserItem != null)
                                                {
                                                    this.m_ItemList.RemoveAt(i);
                                                    UserItem = null;
                                                    UserItem = null;
                                                }
                                                boEatOK = true;
                                            }
                                            break;
                                        case 2:
                                            if (StdItem.AniCount == 21)  // 祝福罐 类型的物品 
                                            {
                                                if (StdItem.Reserved != 56)
                                                {
                                                    if (UserItem.Dura > 0)
                                                    {
                                                        if ((this.m_ItemList.Count - 1) <= Grobal2.MAXBAGITEM)
                                                        {
                                                            if (UserItem.Dura >= 1000)
                                                            {
                                                                UserItem.Dura -= 1000; // 修改为1000
                                                                UserItem.DuraMax -= 1000;// 减少存物品数量
                                                                if (UserItem.DuraMax <= 0)
                                                                {
                                                                    // 不能存取物品,则删除物品
                                                                    if (UserItem != null)
                                                                    {
                                                                        this.m_ItemList.RemoveAt(i);
                                                                        UserItem = null;
                                                                        boEatOK = true;
                                                                    }
                                                                }
                                                            }
                                                            else
                                                            {
                                                                UserItem.Dura = 0;
                                                                UserItem.DuraMax = 0;//减少存物品数量
                                                                if (UserItem.DuraMax <= 0)// 能存取物品,则删除物品
                                                                {
                                                                    if (UserItem != null)
                                                                    {
                                                                        this.m_ItemList.RemoveAt(i);
                                                                        UserItem = null;
                                                                        boEatOK = true;
                                                                    }
                                                                }
                                                            }
                                                            // 需要修改UnbindList.txt,加入 3 祝福油 3---为 祝福罐的外观值
                                                            ClientUseItems_GetUnBindItems(ClientUseItems_GetUnbindItemName(StdItem.Shape), 1);// 给一个祝福油 
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    // 泉水罐
                                                    if (UserItem.Dura >= 1000)
                                                    {
                                                        if ((this.m_ItemList.Count - 1) <= Grobal2.MAXBAGITEM)
                                                        {
                                                            if (UserItem.Dura >= 1000)
                                                            {
                                                                UserItem.Dura -= 1000;
                                                            }
                                                            else
                                                            {
                                                                UserItem.Dura = 0;
                                                            }
                                                            // 需要修改UnbindList.txt,加入 1 泉水   1---为 泉水的外观值
                                                            ClientUseItems_GetUnBindItems(ClientUseItems_GetUnbindItemName(StdItem.Shape), 1);// 给一个泉水
                                                        }
                                                    }
                                                }
                                                boSendUpDate = true;
                                            }
                                            else
                                            {
                                                switch (StdItem.Shape)
                                                {
                                                    case 0:// 计次物品
                                                        if ((StdItem.Source != 0) && (StdItem.Reserved != 0))// 捆绳类物品
                                                        {
                                                            if (UserItem != null)
                                                            {
                                                                if (UserItem.Dura > 0)
                                                                {
                                                                    if (CheckStdmodeFunItem(StdItem))
                                                                    {
                                                                        if (UserItem.Dura >= 1000)
                                                                        {
                                                                            UserItem.Dura -= 1000;
                                                                            boEatOK = true;
                                                                            if (UserItem.Dura > 0)
                                                                            {
                                                                                boSendUpDate = true;
                                                                                boEatOK = false;
                                                                            }
                                                                            else
                                                                            {
                                                                                if (UserItem != null)
                                                                                {
                                                                                    UserItem.wIndex = 0;
                                                                                    this.m_ItemList.RemoveAt(i);
                                                                                    UserItem = null;
                                                                                }
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            UserItem.Dura = 0;
                                                                            if (UserItem != null)
                                                                            {
                                                                                UserItem.wIndex = 0;
                                                                                this.m_ItemList.RemoveAt(i);
                                                                                UserItem = null;
                                                                            }
                                                                        }
                                                                        UseStdmodeFunItem(StdItem);
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    UserItem.wIndex = 0;
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                            // 其它计次物品
                                                            if (UserItem != null)
                                                            {
                                                                if (UserItem.Dura > 0)
                                                                {
                                                                    if (UserItem.Dura >= 1000)
                                                                    {
                                                                        UserItem.Dura -= 1000;
                                                                        boEatOK = true;
                                                                        if (UserItem.Dura > 0)
                                                                        {
                                                                            boSendUpDate = true;
                                                                            boEatOK = false;
                                                                        }
                                                                        else
                                                                        {
                                                                            if (UserItem != null)
                                                                            {
                                                                                UserItem.wIndex = 0;
                                                                                this.m_ItemList.RemoveAt(i);
                                                                                UserItem = null;
                                                                            }
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        UserItem.Dura = 0;
                                                                        if (UserItem != null)
                                                                        {
                                                                            UserItem.wIndex = 0;
                                                                            this.m_ItemList.RemoveAt(i);
                                                                            UserItem = null;
                                                                        }
                                                                    }
                                                                    UseStdmodeFunItem(StdItem);
                                                                }
                                                                else
                                                                {
                                                                    UserItem.wIndex = 0;
                                                                }
                                                            }
                                                        }
                                                        break;
                                                    case 1:// 召唤强化卷
                                                        if (UserItem.Dura > 0)
                                                        {
                                                            if (UserItem.Dura >= 1000)
                                                            {
                                                                if (CallMobeItem())// 召唤强化卷,把招出的宝宝变成7级 
                                                                {
                                                                    UserItem.Dura -= 1000;
                                                                    boEatOK = true;
                                                                }
                                                            }
                                                            else
                                                            {
                                                                UserItem.Dura = 0;
                                                                UserItem.wIndex = 0;
                                                            }
                                                        }
                                                        if (UserItem.Dura > 0)
                                                        {
                                                            boSendUpDate = true;
                                                            boEatOK = false;
                                                        }
                                                        else
                                                        {
                                                            if (UserItem != null)
                                                            {
                                                                this.m_ItemList.RemoveAt(i);
                                                                UserItem = null;
                                                            }
                                                        }
                                                        break;
                                                    case 9://修复神水
                                                        ItemCount = RepairAllItemDura();
                                                        if ((UserItem.Dura > 0) && (ItemCount > 0))
                                                        {
                                                            if (UserItem.Dura >= (ItemCount / 10))
                                                            {
                                                                UserItem.Dura -= (ushort)(ItemCount / 10);
                                                                RepairAllItem(ItemCount / 1000, false);// 全部修复
                                                                if (UserItem.Dura < 100)
                                                                {
                                                                    UserItem.Dura = 0;
                                                                }
                                                            }
                                                            else
                                                            {
                                                                UserItem.Dura = 0;
                                                                RepairAllItem(ItemCount / 1000, true);
                                                            }
                                                        }
                                                        boEatOK = false;
                                                        if (UserItem.Dura > 0)
                                                        {
                                                            boSendUpDate = true;
                                                        }
                                                        else
                                                        {
                                                            if (UserItem != null)
                                                            {
                                                                this.m_ItemList.RemoveAt(i);
                                                                UserItem = null;
                                                            }
                                                            boEatOK = true;
                                                        }
                                                        break;
                                                    case 2:// 随机传送石
                                                        if (!this.m_PEnvir.m_boNORANDOMMOVE)   // 地图没有禁止随机传送时才能使用
                                                        {
                                                            if (UserItem.Dura > 0)
                                                            {
                                                                if (UserItem.Dura >= 1000)
                                                                {
                                                                    UserItem.Dura -= 1000;
                                                                }
                                                                else
                                                                {
                                                                    UserItem.Dura = 0;
                                                                    UserItem.wIndex = 0;
                                                                }
                                                                boEatOK = true;
                                                                RandomMove();
                                                            }
                                                            if (UserItem.Dura > 0)
                                                            {
                                                                boSendUpDate = true;
                                                                boEatOK = false;
                                                            }
                                                            else
                                                            {
                                                                if (UserItem != null)
                                                                {
                                                                    this.m_ItemList.RemoveAt(i);
                                                                    UserItem = null;
                                                                }
                                                            }
                                                        }
                                                        break;
                                                    case 3:
                                                        switch (StdItem.AniCount)// 双倍卷轴 双倍秘籍 双倍宝典 使用时,必进入这里,是脚本触发 ActionOfKillMonExpRate
                                                        {
                                                            case 15:
                                                            case 16:
                                                            case 17:
                                                                if (UserItem.Dura > 0)
                                                                {
                                                                    if (UserItem.Dura >= 1000) // 100
                                                                    {
                                                                        UserItem.Dura -= 1000;// 100
                                                                    }
                                                                    else
                                                                    {
                                                                        UserItem.Dura = 0;
                                                                        UserItem.wIndex = 0;
                                                                    }
                                                                    m_nKillMonExpRate = m_nKillMonExpRate * 2;// 调整杀怪经验为双倍数
                                                                    m_nOldKillMonExpRate = m_nKillMonExpRate;
                                                                    m_dwKillMonExpRateTime = Convert.ToUInt16(m_dwKillMonExpRateTime + 180);// 经验倍数时间(秒)
                                                                    if (m_MyHero != null) // 英雄也同时双倍经验 
                                                                    {
                                                                        ((THeroObject)(m_MyHero)).m_nKillMonExpRate = ((THeroObject)(m_MyHero)).m_nKillMonExpRate * 2;
                                                                        ((THeroObject)(m_MyHero)).m_nOldKillMonExpRate = ((THeroObject)(m_MyHero)).m_nKillMonExpRate;
                                                                    }
                                                                    this.SysMsg(string.Format(GameMsgDef.g_sChangeKillMonExpRateMsg, m_nKillMonExpRate / 100, m_dwKillMonExpRateTime), TMsgColor.c_Green, TMsgType.t_Hint);
                                                                    boEatOK = true;
                                                                }
                                                                if (UserItem.Dura > 0)
                                                                {
                                                                    boSendUpDate = true;
                                                                    boEatOK = false;
                                                                }
                                                                else
                                                                {
                                                                    if (UserItem != null)
                                                                    {
                                                                        this.m_ItemList.RemoveAt(i);
                                                                        UserItem = null;
                                                                        UserItem = null;
                                                                    }
                                                                }
                                                                break;
                                                        }
                                                        break;
                                                }
                                            }
                                            break;
                                        case 4:// 书
                                            if (ReadBook(StdItem))
                                            {
                                                if (UserItem != null)
                                                {
                                                    this.m_ItemList.RemoveAt(i);
                                                    UserItem = null;
                                                    UserItem = null;
                                                }
                                                boEatOK = true;
                                            }
                                            break;
                                        case 7:// 使用次数  {数据库中没有分类是7的物品}
                                            switch (StdItem.Shape)
                                            {
                                                case 0:// 修复神水
                                                    if (UserItem.Dura > 0)
                                                    {
                                                        if (UserItem.Dura >= 1000)
                                                        {
                                                            UserItem.Dura -= 1000;
                                                        }
                                                        else
                                                        {
                                                            UserItem.Dura = 0;
                                                            UserItem.wIndex = 0;
                                                        }
                                                        boEatOK = true;
                                                    }
                                                    if (UserItem.Dura > 0)
                                                    {
                                                        boSendUpDate = true;
                                                        boEatOK = false;
                                                    }
                                                    else
                                                    {
                                                        if (UserItem != null)
                                                        {
                                                            this.m_ItemList.RemoveAt(i);
                                                            UserItem = null;
                                                        }
                                                    }
                                                    break;
                                            }
                                            break;
                                        case 31:// 解包物品
                                            if (HUtil32.rangeInDefined(StdItem.AniCount, 0, 3))
                                            {
                                                if ((this.m_ItemList.Count + 6 - 1) <= Grobal2.MAXBAGITEM)
                                                {
                                                    if (UserItem != null)
                                                    {
                                                        this.m_ItemList.RemoveAt(i);
                                                        UserItem = null;
                                                    }
                                                    ClientUseItems_GetUnBindItems(ClientUseItems_GetUnbindItemName(StdItem.Shape), 6);
                                                    boEatOK = true;
                                                }
                                            }
                                            if (HUtil32.rangeInDefined(StdItem.AniCount, 4, 255))
                                            {
                                                switch (StdItem.Shape)
                                                {
                                                    case 0:
                                                        if (ClientUseItems_FoundUserItem(UserItem))// 先查找物品，删除物品后再触发
                                                        {
                                                            if (UserItem != null)
                                                            {
                                                                this.m_ItemList.RemoveAt(i);
                                                                ClearCopyItem(0, UserItem.wIndex, UserItem.MakeIndex);// 清理复制品
                                                                UserItem = null;
                                                                UseStdmodeFunItem(StdItem);// 使用物品触发脚本段
                                                            }
                                                            boEatOK = true;
                                                        }
                                                        break;
                                                    case 1:
                                                        if (ItemDblClick(StdItem.Name, UserItem.MakeIndex, ref sMapName, ref nCurrX, ref nCurrY))
                                                        {
                                                            if (UserItem != null)
                                                            {
                                                                this.m_ItemList.RemoveAt(i);
                                                                UserItem = null;
                                                            }
                                                            this.SpaceMove(sMapName, nCurrX, nCurrY, 0);
                                                            boEatOK = true;
                                                        }
                                                        else
                                                        {
                                                            this.SendMsg(M2Share.g_ManageNPC, Grobal2.RM_MENU_OK, 0, this.m_ActorsId, 0, 0,
                                                                  "当前地图坐标保存成功！！！\\再次双击，将传送到\\地图：" + this.m_sMapName + " 坐标：" + this.m_nCurrX + ":" + this.m_nCurrY);
                                                        }
                                                        break;
                                                }
                                            }
                                            break;
                                        case 51:// 31 聚灵珠
                                            if (StdItem.Shape == 0)
                                            {
                                                if (UserItem.btValue[12] == 2)// 聚集满了经验，或是聚集时间到,才可使用
                                                {
                                                    dwExp = Convert.ToInt32(UserItem.Dura * 10000);
                                                    if (m_MyHero != null)
                                                    {
                                                        ((THeroObject)(m_MyHero)).GetExp((int)Math.Abs(HUtil32.Round((double)(M2Share.g_Config.nHeroNoKillMonExpRate / 100) * dwExp)));
                                                        dwExp = (int)Math.Abs(HUtil32.Round((double)((100 - M2Share.g_Config.nHeroNoKillMonExpRate) / 100) * dwExp));
                                                    }
                                                    if (this.m_Abil.Exp >= dwExp)
                                                    {
                                                        if ((int.MaxValue - this.m_Abil.Exp) < dwExp)
                                                        {
                                                            dwExp = int.MaxValue - this.m_Abil.Exp;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        if ((int.MaxValue - dwExp) < this.m_Abil.Exp)
                                                        {
                                                            dwExp = int.MaxValue - dwExp;
                                                        }
                                                    }
                                                    m_GetExp = dwExp;// 人物取得的经验,$GetExp变量使用
                                                    if (M2Share.g_FunctionNPC != null)
                                                    {
                                                        M2Share.g_FunctionNPC.GotoLable(this, "@GetExp", false);// 取经验触发
                                                    }
                                                    this.m_Abil.Exp += dwExp;
                                                    this.SendMsg(this, Grobal2.RM_WINEXP, 0, (int)dwExp, 0, 0, "");
                                                    if (this.m_Abil.Exp >= this.m_Abil.MaxExp)
                                                    {
                                                        this.m_Abil.Exp -= this.m_Abil.MaxExp;
                                                        if ((this.m_Abil.Level < M2Share.MAXUPLEVEL) && (this.m_Abil.Level < M2Share.g_Config.nLimitExpLevel))
                                                        {
                                                            this.m_Abil.Level++; // 增加限制等级
                                                        }
                                                        if (this.m_Abil.Level < M2Share.g_Config.nLimitExpLevel)
                                                        {
                                                            this.HasLevelUp(this.m_Abil.Level - 1); // 增加限制等级
                                                        }
                                                        // 人物升级记录日志
                                                        M2Share.AddGameDataLog("12" + "\09" + this.m_sMapName + "\09" + (this.m_Abil.Level).ToString()
                                                            + "\09" + (this.m_Abil.Exp).ToString() + "/" + (this.m_Abil.MaxExp).ToString() + "\09"
                                                            + this.m_sCharName + "\09" + "0" + "\09" + "0" + "\09" + "1" + "\09" + "聚灵珠");
                                                    }
                                                    if (this.m_MagicArr[0][MagicConst.SKILL_68] != null)// 学过酒气护体
                                                    {
                                                        if (this.m_MagicArr[0][MagicConst.SKILL_68].btLevel < 100)
                                                        {
                                                            m_Exp68 += (UInt16)dwExp;
                                                        }
                                                        if (m_Exp68 >= m_MaxExp68)// 超过升级经验,则升级技能
                                                        {
                                                            m_Exp68 -= m_MaxExp68;
                                                            if (this.m_MagicArr[0][MagicConst.SKILL_68].btLevel < 100)
                                                            {
                                                                this.m_MagicArr[0][MagicConst.SKILL_68].btLevel++;
                                                            }
                                                            m_MaxExp68 = (UInt16)this.GetSkill68Exp(this.m_MagicArr[0][MagicConst.SKILL_68].btLevel);
                                                            this.SendDelayMsg(this, Grobal2.RM_MAGIC_LVEXP, 0, this.m_MagicArr[0][MagicConst.SKILL_68].MagicInfo.wMagicId,
                                                                this.m_MagicArr[0][MagicConst.SKILL_68].btLevel, this.m_MagicArr[0][MagicConst.SKILL_68].nTranPoint, "", 100);
                                                        }
                                                        if (this.m_MagicArr[0][MagicConst.SKILL_68].btLevel < 100)
                                                        {
                                                            // 发送酒气护体经验
                                                            this.SendMsg(this, Grobal2.RM_MAGIC68SKILLEXP, 0, 0, 0, 0, EncryptUnit.EncodeString(m_Exp68.ToString()) + "/" + m_MaxExp68.ToString());
                                                        }
                                                    }
                                                    if (UserItem != null)
                                                    {
                                                        this.m_ItemList.RemoveAt(i);
                                                        UserItem = null;
                                                    }
                                                    boEatOK = true;
                                                }
                                            }
                                            break;
                                        case 60:// 51 饮酒
                                            if ((StdItem.Shape != 0))// 除烧酒外
                                            {
                                                if (!n_DrinkWineDrunk) // 没有喝醉
                                                {
                                                    if (this.m_Abil.MaxAlcohol >= StdItem.Need)// 酒量值达到要求
                                                    {
                                                        if (UserItem.Dura > 0)
                                                        {
                                                            if (UserItem.Dura >= 1000)
                                                            {
                                                                UserItem.Dura -= 1000;
                                                            }
                                                            else
                                                            {
                                                                UserItem.Dura = 0;
                                                            }
                                                            this.SendRefMsg(Grobal2.RM_MYSHOW, 7, 0, 0, 0, "");// 喝酒自身动画 
                                                            if (this.m_Abil.WineDrinkValue == 0)// 如果醉酒度为0,则初始时间间隔
                                                            {
                                                                m_dwDecWineDrinkValueTick = HUtil32.GetTickCount();
                                                                m_dwAddAlcoholTick = HUtil32.GetTickCount();
                                                            }
                                                            this.m_Abil.WineDrinkValue += (ushort)(UserItem.btValue[1] * this.m_Abil.MaxAlcohol / 200);// 增加醉酒度
                                                            n_DrinkWineAlcohol = (byte)UserItem.btValue[1];// 饮酒时酒的度数
                                                            n_DrinkWineQuality = (byte)UserItem.btValue[0];// 饮酒时酒的品质
                                                            if (this.m_Abil.WineDrinkValue >= this.m_Abil.MaxAlcohol) // 醉酒度超过上限,即喝醉了
                                                            {
                                                                this.m_Abil.WineDrinkValue = this.m_Abil.MaxAlcohol;
                                                                this.n_DrinkWineDrunk = true;// 喝酒醉了
                                                                this.SysMsg("自觉头晕不已,酒虽为情所系,奈何量去甚多,暂无余力再饮!", TMsgColor.c_Red, TMsgType.t_Hint);
                                                                this.SendRefMsg(Grobal2.RM_MYSHOW, 9, 0, 0, 0, "");// 喝醉自身动画 
                                                            }
                                                            // 普通酒,品质2以上,25%机率加临时属性
                                                            if ((StdItem.AniCount == 1) && (n_DrinkWineQuality > 2) && (HUtil32.Random(4) == 0) && !n_DrinkWineDrunk)
                                                            {
                                                                switch (HUtil32.Random(2))
                                                                {
                                                                    case 0:// 增加防御力300秒
                                                                        this.DefenceUp(300);
                                                                        break;
                                                                    case 1:// 增加魔御300秒
                                                                        this.MagDefenceUp(300);
                                                                        break;
                                                                }
                                                            }
                                                            if ((StdItem.AniCount == 2) && !n_DrinkWineDrunk)  // 药酒可增加药力值
                                                            {
                                                                if (n_DrinkWineQuality > 4)// 品质为4以上,药酒增加临时属性
                                                                {
                                                                    switch (StdItem.Shape)
                                                                    {
                                                                        case 8:
                                                                            switch (this.m_btJob)
                                                                            {
                                                                                case 0:// 虎骨酒 增加攻击上限,魔法上限或道术上限2点,效果持续600秒
                                                                                    this.m_wStatusArrValue[0] = 2;
                                                                                    this.m_dwStatusArrTimeOutTick[0] = HUtil32.GetTickCount() + 600000; // 600 * 1000
                                                                                    break;
                                                                                case 1:
                                                                                    this.m_wStatusArrValue[1] = 2;
                                                                                    this.m_dwStatusArrTimeOutTick[1] = HUtil32.GetTickCount() + 600000; // 600 * 1000
                                                                                    break;
                                                                                case 2:
                                                                                    this.m_wStatusArrValue[2] = 2;
                                                                                    this.m_dwStatusArrTimeOutTick[2] = HUtil32.GetTickCount() + 600000; // 600 * 1000
                                                                                    break;
                                                                            }
                                                                            break;
                                                                        case 9:// 金箔酒  增加生命值上限100点,效果持续600秒
                                                                            this.m_wStatusArrValue[4] = 100;
                                                                            this.m_dwStatusArrTimeOutTick[4] = HUtil32.GetTickCount() + 600000;// 600 * 1000
                                                                            break;
                                                                        case 10:// 活脉酒  增加敏捷2点,效果持续600秒
                                                                            this.m_wStatusArrValue[11] = 2;
                                                                            this.m_dwStatusArrTimeOutTick[11] = HUtil32.GetTickCount() + 600000;// 600 * 1000
                                                                            break;
                                                                        case 11:// 玄参酒  增加防御上限4点,效果持续600秒
                                                                            this.m_wStatusTimeArr[9] = 4;
                                                                            this.m_dwStatusArrTimeOutTick[9] = HUtil32.GetTickCount() + 600000;// 600 * 1000
                                                                            break;
                                                                        case 12:// 蛇胆酒  增加魔法值上限200点,效果持续600秒
                                                                            this.m_wStatusArrValue[5] = 200;
                                                                            this.m_dwStatusArrTimeOutTick[5] = HUtil32.GetTickCount() + 600000; // 600 * 1000
                                                                            break;
                                                                    }
                                                                }
                                                                dw_UseMedicineTime = M2Share.g_Config.nDesMedicineTick;// 始化使用药酒时间(12小时)
                                                                this.m_Abil.MedicineValue += (ushort)UserItem.btValue[2];// 增加药力值
                                                                if (this.m_Abil.MedicineValue >= this.m_Abil.MaxMedicineValue) // 当前药力值达到当前等级上限时
                                                                {
                                                                    this.m_Abil.MedicineValue -= this.m_Abil.MaxMedicineValue;
                                                                    switch ((n_MedicineLevel % 6))
                                                                    {
                                                                        case 0:// 增加永久属性
                                                                            switch (this.m_btJob)
                                                                            {
                                                                                case 0:// 攻击/魔法/道术上限(看职业)
                                                                                    this.m_Abil.DC = HUtil32.MakeLong(this.m_Abil.DC, this.m_Abil.DC + 1);
                                                                                    break;
                                                                                case 1:
                                                                                    this.m_Abil.MC = HUtil32.MakeLong(this.m_Abil.MC, this.m_Abil.MC + 1);
                                                                                    break;
                                                                                case 2:
                                                                                    this.m_Abil.SC = HUtil32.MakeLong(this.m_Abil.SC, this.m_Abil.SC + 1);
                                                                                    break;
                                                                            }
                                                                            break;
                                                                        case 1:// 加魔御下限
                                                                            this.m_Abil.MAC = HUtil32.MakeLong(this.m_Abil.MAC + 1, this.m_Abil.MAC);
                                                                            break;
                                                                        case 2:// 加防御下限
                                                                            this.m_Abil.AC = HUtil32.MakeLong(this.m_Abil.AC + 1, this.m_Abil.AC);
                                                                            break;
                                                                        case 3:
                                                                            switch (this.m_btJob)
                                                                            {
                                                                                case 0:// 攻击/魔法/道术下限(看职业)
                                                                                    this.m_Abil.DC = HUtil32.MakeLong(this.m_Abil.DC + 1, this.m_Abil.DC);
                                                                                    break;
                                                                                case 1:
                                                                                    this.m_Abil.MC = HUtil32.MakeLong(this.m_Abil.MC + 1, this.m_Abil.MC);
                                                                                    break;
                                                                                case 2:
                                                                                    this.m_Abil.SC = HUtil32.MakeLong(this.m_Abil.SC + 1, this.m_Abil.SC);
                                                                                    break;
                                                                            }
                                                                            break;
                                                                        case 4:  // 魔御上限
                                                                            this.m_Abil.MAC = HUtil32.MakeLong(this.m_Abil.MAC, this.m_Abil.MAC + 1);
                                                                            break;
                                                                        case 5: // 防御上限
                                                                            this.m_Abil.AC = HUtil32.MakeLong(this.m_Abil.AC, this.m_Abil.AC + 1);
                                                                            break;
                                                                    }
                                                                    if (n_MedicineLevel < M2Share.MAXUPLEVEL)
                                                                    {
                                                                        n_MedicineLevel++; // 增加等级
                                                                    }
                                                                    this.m_Abil.MaxMedicineValue = this.GetMedicineExp(n_MedicineLevel);// 取升级后的等级对应的药力值
                                                                    this.SysMsg("酒劲在周身弥漫,感觉身体状态有所改变", TMsgColor.c_Red, TMsgType.t_Hint);
                                                                }
                                                            }
                                                            RecalcAbilitys();
                                                            this.CompareSuitItem(false);// 套装与身上装备对比
                                                            this.SendMsg(this, Grobal2.RM_ABILITY, 0, 0, 0, 0, "");
                                                            boEatOK = true;
                                                        }
                                                        if (UserItem.Dura > 0)
                                                        {
                                                            boSendUpDate = true;
                                                            boEatOK = false;
                                                        }
                                                        else
                                                        {
                                                            if (UserItem != null)
                                                            {
                                                                UserItem.wIndex = 0;
                                                                this.m_ItemList.RemoveAt(i);
                                                                UserItem = null;
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        this.SysMsg("酒量需达到" + StdItem.Need + "才能饮用!", TMsgColor.c_Red, TMsgType.t_Hint);
                                                    }
                                                }
                                                else
                                                {
                                                    this.SysMsg("自觉头晕不已,酒虽为情所系,奈何量去甚多,暂无余力再饮!", TMsgColor.c_Red, TMsgType.t_Hint);
                                                }
                                            }
                                            break;
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    this.SendMsg(M2Share.g_ManageNPC, Grobal2.RM_MENU_OK, 0, this.m_ActorsId, 0, 0, GameMsgDef.g_sCanotUseItemMsg);
                }
                if (boEatOK)
                {
                    this.WeightChanged();
                    SendDefMessage(Grobal2.SM_EAT_OK, 0, 0, 0, 0, "");
                    if (StdItem.NeedIdentify == 1)
                    {
                        M2Share.AddGameDataLog("11" + "\09" + this.m_sMapName + "\09" + (this.m_nCurrX).ToString() + "\09" +
                            (this.m_nCurrY).ToString() + "\09" + this.m_sCharName + "\09" + StdItem.Name + "\09" + (UserItem34.MakeIndex).ToString() + "\09"
                            + "(" + (HUtil32.LoWord(StdItem.DC)).ToString() + "/" + (HUtil32.HiWord(StdItem.DC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MC)).ToString() + "/"
                            + (HUtil32.HiWord(StdItem.MC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.SC)).ToString() + "/" + (HUtil32.HiWord(StdItem.SC)).ToString() + ")" + "("
                            + (HUtil32.LoWord(StdItem.AC)).ToString() + "/" + (HUtil32.HiWord(StdItem.AC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MAC)).ToString() + "/"
                            + (HUtil32.HiWord(StdItem.MAC)).ToString() + ")" + (UserItem34.btValue[0]).ToString() + "/" + (UserItem34.btValue[1]).ToString() + "/"
                            + (UserItem34.btValue[2]).ToString() + "/" + (UserItem34.btValue[3]).ToString() + "/" + (UserItem34.btValue[4]).ToString()
                            + "/" + (UserItem34.btValue[5]).ToString() + "/" + (UserItem34.btValue[6]).ToString() + "/" + (UserItem34.btValue[7]).ToString()
                            + "/" + (UserItem34.btValue[8]).ToString() + "/" + (UserItem34.btValue[14]).ToString() + "\09" + "0");
                    }
                }
                else
                {
                    SendDefMessage(Grobal2.SM_EAT_FAIL, 0, 0, 0, 0, "");
                }
                if ((UserItem != null) && boSendUpDate)
                {
                    SendUpdateItem(UserItem);
                }
            }
            finally
            {
                m_boCanQueryBag = false;
            }
        }

        /// <summary>
        /// 客户端挖尸体东西
        /// </summary>
        /// <returns></returns>
        private bool ClientGetButchItem(TBaseObject BaseObject, int nX, int nY, byte btDir, ref uint dwDelayTime)
        {
            bool result;
            int n10;
            int n14;
            uint dwCheckTime;
            bool Butch;
            int ButchChargeCount;
            int ButchChargeClass;
            TStdItem StdItem;
            TUserItem UserItem = null;
            string sCheckItemName;
            TMonItemInfo MonItem;
            byte nItemCount;// 进入触发段前的包裹物品数量
            ushort nLevel;// 进入触发段前的等级
            int nExp;// 进入触发段前的经验
            int nGameDiamond;
            int nCreditPoint;
            int nGameGird;// 进入触发段前的金刚石,声望,灵符
            byte nCode; // 异常提示
            result = false;
            Butch = false;
            int K;
            if ((BaseObject == null) || (this.m_boGhost) || (this.m_boDeath))//人死后不能挖人形物品
            {
                return result;
            }
            if (BaseObject.m_boGhost)
            {
                return result;
            }
            if (HUtil32.GetTickCount() - BaseObject.m_dwDeathTick > (M2Share.g_Config.dwMakeGhostPlayMosterTime - 2000))//快要清理尸体时，则不再进入
            {
                return result;
            }
            nCode = 36;
            dwDelayTime = 0;
            nItemCount = 0;
            nLevel = 0;
            nExp = 0;
            nGameDiamond = 0;
            nCreditPoint = 0;
            nGameGird = 0;
            ButchChargeCount = 0;
            dwCheckTime = HUtil32.GetTickCount() - m_dwTurnTick;
            if (dwCheckTime < M2Share.g_Config.dwTurnIntervalTime)
            {
                dwDelayTime = M2Share.g_Config.dwTurnIntervalTime - dwCheckTime;
                return result;
            }
            m_dwTurnTick = HUtil32.GetTickCount();
            try
            {
                switch (BaseObject.m_btRaceServer)
                {
                    case 121:// 巨镰蜘蛛
                        ButchChargeClass = ((TGiantSickleSpiderATMonster)(BaseObject)).m_nButchChargeClass;
                        nCode = 42;
                        if (BaseObject.m_boDeath && (!BaseObject.m_boGhost) && (!BaseObject.m_boSkeleton) && (BaseObject.m_Master == null) && (BaseObject.m_btSlaveMakeLevel == 0))
                        {
                            nCode = 43;
                            ButchChargeCount = ((TGiantSickleSpiderATMonster)(BaseObject)).m_nButchChargeCount;
                            switch (ButchChargeClass)
                            {
                                case 0:// 挖取身上装备收费模式,并减少人物相应的数值 金币模式
                                    if (this.m_nGold >= ButchChargeCount)
                                    {
                                        Butch = true;
                                    }
                                    else
                                    {
                                        this.SysMsg("您的金币没有达到" + ButchChargeCount + ",将挖取不到任何物品!", TMsgColor.c_Red, TMsgType.t_Hint);
                                    }
                                    break;
                                case 1:// 元宝模式
                                    if (m_nGameGold >= ButchChargeCount)
                                    {
                                        Butch = true;
                                    }
                                    else
                                    {
                                        this.SysMsg("您的" + M2Share.g_Config.sGameGoldName + "没有达到" + ButchChargeCount + ",将挖取不到任何物品!", TMsgColor.c_Red, TMsgType.t_Hint);
                                    }
                                    break;
                                case 2:// 金刚石模式
                                    if (m_nGAMEDIAMOND >= ButchChargeCount)
                                    {
                                        Butch = true;
                                    }
                                    else
                                    {
                                        this.SysMsg("您的" + M2Share.g_Config.sGameDiaMond + "没有达到" + ButchChargeCount + ",将挖取不到任何物品!", TMsgColor.c_Red, TMsgType.t_Hint);
                                    }
                                    break;
                                case 3:// 灵符模式
                                    if (m_nGAMEGIRD >= ButchChargeCount)
                                    {
                                        Butch = true;
                                    }
                                    else
                                    {
                                        this.SysMsg("您的" + M2Share.g_Config.sGameGird + "没有达到" + ButchChargeCount + ",将挖取不到任何物品!", TMsgColor.c_Red, TMsgType.t_Hint);
                                    }
                                    break;
                            }
                            nCode = 44;
                            if (Butch)
                            {
                                switch (HUtil32.Random(3))
                                {
                                    case 0:// 挖所需的条件达到 随机处理挖 挖取列表中的物品
                                        nCode = 45;
                                        if ((BaseObject != null))
                                        {
                                            if (BaseObject.m_boGhost)
                                            {
                                                return result;
                                            }
                                            if (BaseObject.m_boButchSkeleton) // 正在被挖尸体
                                            {
                                                return result;
                                            }
                                            BaseObject.m_boButchSkeleton = true;
                                            try
                                            {
                                                for (int i = ((TGiantSickleSpiderATMonster)(BaseObject)).m_ButchItemList.Count - 1; i >= 0; i--)
                                                {
                                                    if (BaseObject.m_boGhost)
                                                    {
                                                        return result;
                                                    }
                                                    if (HUtil32.GetTickCount() - BaseObject.m_dwDeathTick > (M2Share.g_Config.dwMakeGhostPlayMosterTime - 2000)) // 如果快要清理尸体时，则不再进入
                                                    {
                                                        return result;
                                                    }
                                                    if (((TGiantSickleSpiderATMonster)BaseObject).m_ButchItemList.Count <= 0)
                                                    {
                                                        break;
                                                    }
                                                    MonItem = ((TMonItemInfo)(((TGiantSickleSpiderATMonster)(BaseObject)).m_ButchItemList[i]));
                                                    if ((MonItem.ItemName).ToLower().CompareTo((M2Share.sSTRING_GOLDNAME).ToLower()) == 0) // 如果是金币
                                                    {
                                                        nCode = 46;
                                                        this.m_nGold = this.m_nGold + MonItem.Count;
                                                        if (MonItem.Count > 0)
                                                        {
                                                            if (M2Share.g_boGameLogGold)
                                                            {
                                                                M2Share.AddGameDataLog("37" + "\09" + this.m_sMapName + "\09" + (this.m_nCurrX).ToString() + "\09"
                                                                    + (this.m_nCurrY).ToString() + "\09" + this.m_sCharName + "\09" + M2Share.sSTRING_GOLDNAME + "\09"
                                                                    + (MonItem.Count).ToString() + "\09" + "1" + "\09" + BaseObject.m_sCharName);
                                                            }
                                                        }
                                                        this.GoldChanged();
                                                        if (BaseObject != null)
                                                        {
                                                            ((TGiantSickleSpiderATMonster)BaseObject).m_ButchItemList.RemoveAt(i);
                                                        }
                                                        switch (ButchChargeClass)
                                                        {
                                                            case 0:// 挖到后,删除对应的物品 挖取到物品后减所需的条件的数量  金币模式
                                                                this.m_nGold -= ButchChargeCount;
                                                                this.GoldChanged();
                                                                break;
                                                            case 1:// 更新玩家的金币// 元宝模式
                                                                m_nGameGold -= ButchChargeCount;
                                                                this.GameGoldChanged();
                                                                break;
                                                            case 2:// 更新元宝数量 金刚石模式
                                                                m_nGAMEDIAMOND -= ButchChargeCount;
                                                                this.GameGoldChanged();
                                                                break;
                                                            case 3:// 更新金刚石数量 灵符模式
                                                                m_nGAMEGIRD -= ButchChargeCount;
                                                                this.GameGoldChanged();// 更新灵符数量
                                                                m_UseGameGird = ButchChargeCount;// 灵符使用计数
                                                                if (M2Share.g_FunctionNPC != null) // 灵符使用触发
                                                                {
                                                                    M2Share.g_FunctionNPC.GotoLable(this, "@USEGAMEGIRD", false);
                                                                }
                                                                break;
                                                        }
                                                        this.SendRefMsg(Grobal2.RM_MYSHOW, Grobal2.ET_OBJECTBUTCHMON, 0, 0, 0, "");// 挖尸体得到物品显示
                                                        break;
                                                    }
                                                    else
                                                    {
                                                        UserItem = new TUserItem();
                                                        if (M2Share.UserEngine.CopyToUserItemFromName(MonItem.ItemName, UserItem))
                                                        {
                                                            nCode = 47;
                                                            UserItem.Dura = (ushort)HUtil32.Round((double)(UserItem.DuraMax / 100) * (20 + HUtil32.Random(80)));
                                                            if (HUtil32.Random(M2Share.g_Config.nPlayMonRandomAddValue) == 0)
                                                            {
                                                                M2Share.UserEngine.RandomUpgradeItem(UserItem);
                                                            }
                                                            nCode = 48;
                                                            if ((UserItem != null))
                                                            {
                                                                nCode = 49;
                                                                switch (ButchChargeClass)
                                                                {
                                                                    case 0:// 挖取到物品后减所需的条件的数量 金币模式
                                                                        this.m_nGold -= ButchChargeCount;
                                                                        this.GoldChanged();
                                                                        break;
                                                                    case 1:// 更新玩家的金币 元宝模式
                                                                        m_nGameGold -= ButchChargeCount;
                                                                        this.GameGoldChanged();
                                                                        break;
                                                                    case 2:// 更新元宝数量 金刚石模式
                                                                        m_nGAMEDIAMOND -= ButchChargeCount;
                                                                        this.GameGoldChanged();
                                                                        break;
                                                                    case 3:// 更新金刚石数量 灵符模式
                                                                        m_nGAMEGIRD -= ButchChargeCount;
                                                                        this.GameGoldChanged();// 更新灵符数量 
                                                                        m_UseGameGird = ButchChargeCount;//灵符使用计数
                                                                        if (M2Share.g_FunctionNPC != null)
                                                                        {
                                                                            M2Share.g_FunctionNPC.GotoLable(this, "@USEGAMEGIRD", false);// 灵符使用触发
                                                                        }
                                                                        break;
                                                                }
                                                                nCode = 50;
                                                                if (BaseObject != null)
                                                                {
                                                                    ((TGiantSickleSpiderATMonster)(BaseObject)).m_ButchItemList.RemoveAt(i);// 挖到后,删除对应的物品
                                                                }
                                                                this.SendRefMsg(Grobal2.RM_MYSHOW, Grobal2.ET_OBJECTBUTCHMON, 0, 0, 0, "");// 挖尸体得到物品显示
                                                                sCheckItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                                                                this.PlugOfCheckCanItem(7, sCheckItemName, false, 0, 0);// 禁止物品规则(管理插件功能)
                                                                if (IsEnoughBag()) // 人物的包裹是否满了
                                                                {
                                                                    StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                                                    if (this.IsAddWeightAvailable(StdItem.Weight)) // 人物的负重没有超过
                                                                    {
                                                                        if (StdItem.NeedIdentify == 1)
                                                                        {
                                                                            M2Share.AddGameDataLog("37" + "\09" + this.m_sMapName + "\09" + (this.m_nCurrX).ToString()
                                                                                + "\09" + (this.m_nCurrY).ToString() + "\09" + this.m_sCharName + "\09" + StdItem.Name
                                                                                + "\09" + (UserItem.MakeIndex).ToString() + "\09" + "(" + (HUtil32.LoWord(StdItem.DC)).ToString()
                                                                                + "/" + (HUtil32.HiWord(StdItem.DC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MC)).ToString()
                                                                                + "/" + (HUtil32.HiWord(StdItem.MC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.SC)).ToString()
                                                                                + "/" + (HUtil32.HiWord(StdItem.SC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.AC)).ToString()
                                                                                + "/" + (HUtil32.HiWord(StdItem.AC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MAC)).ToString()
                                                                                + "/" + (HUtil32.HiWord(StdItem.MAC)).ToString() + ")" + (UserItem.btValue[0]).ToString() + "/"
                                                                                + (UserItem.btValue[1]).ToString() + "/" + (UserItem.btValue[2]).ToString() + "/"
                                                                                + (UserItem.btValue[3]).ToString() + "/" + (UserItem.btValue[4]).ToString() + "/"
                                                                                + (UserItem.btValue[5]).ToString() + "/" + (UserItem.btValue[6]).ToString() + "/"
                                                                                + (UserItem.btValue[7]).ToString() + "/" + (UserItem.btValue[8]).ToString() + "/"
                                                                                + (UserItem.btValue[14]).ToString() + "\09" + BaseObject.m_sCharName);
                                                                        }
                                                                        this.m_ItemList.Add(UserItem);
                                                                        nCode = 51;
                                                                        if (this.m_btRaceServer == Grobal2.RC_PLAYOBJECT)
                                                                        {
                                                                            nCode = 52;
                                                                            SendAddItem(UserItem);// 一次只给玩家一件物品
                                                                            SendUpdateItem(UserItem);// 更新物品
                                                                        }
                                                                        break;
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    nCode = 53;
                                                                    this.DropItemDown(UserItem, 3, false, false, this, this);// 一次只给玩家一件物品
                                                                    this.SysMsg(GameMsgDef.sButchEnoughBagHintMsg, TMsgColor.c_Red, TMsgType.t_Hint);// '您的包裹已没有办法装下任何物品!'
                                                                    break;
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                           UserItem=null;
                                                        }
                                                    }
                                                }
                                            }
                                            finally
                                            {
                                                BaseObject.m_boButchSkeleton = false;
                                            }
                                        }
                                        break;
                                    case 1:
                                    case 2:// 0 进入触发段
                                        if (!IsEnoughBag())
                                        {
                                            this.SysMsg(GameMsgDef.sButchEnoughBagHintMsg, TMsgColor.c_Red, TMsgType.t_Hint);// '您的包裹已没有办法装下任何物品!'
                                        }
                                        if ((M2Share.g_FunctionNPC != null) && ((TGiantSickleSpiderATMonster)(BaseObject)).boIntoTrigger && IsEnoughBag())
                                        {
                                            if (M2Share.g_FunctionNPC.m_boGotoCount < 80) // 防止Goto数量过多,引起M2挂死
                                            {
                                                nItemCount = (byte)this.m_ItemList.Count;// 进入触发段前的包裹物品数量
                                                nLevel = this.m_Abil.Level;// 进入触发段前的等级
                                                nExp = this.m_Abil.Exp;// 进入触发段前的经验
                                                nGameDiamond = m_nGAMEDIAMOND;// 进入触发段前的金刚石
                                                nCreditPoint = m_btCreditPoint;// 进入触发段前的声望
                                                nGameGird = m_nGAMEGIRD;// 进入触发段前的灵符
                                                M2Share.g_FunctionNPC.GotoLable(this, "@ButchCloneItem" + BaseObject.m_sCharName, false);
                                                if ((nItemCount < this.m_ItemList.Count) || ((nExp < this.m_Abil.Exp) && (nLevel == this.m_Abil.Level)) ||
                                                    ((nExp > this.m_Abil.Exp) && (nLevel < this.m_Abil.Level)) || (nGameDiamond < m_nGAMEDIAMOND) || (nCreditPoint < m_btCreditPoint)
                                                    || (nGameGird < m_nGAMEGIRD))
                                                {
                                                    switch (ButchChargeClass)
                                                    {
                                                        case 0:// 挖取到物品后减所需的条件的数量 金币模式
                                                            this.m_nGold -= ButchChargeCount;
                                                            this.GoldChanged();
                                                            break;
                                                        case 1:// 更新玩家的金币 元宝模式
                                                            m_nGameGold -= ButchChargeCount;
                                                            this.GameGoldChanged();
                                                            break;
                                                        case 2:// 更新元宝数量 金刚石模式
                                                            m_nGAMEDIAMOND -= ButchChargeCount;
                                                            this.GameGoldChanged();
                                                            break;
                                                        case 3:// 更新金刚石数量 灵符模式
                                                            m_nGAMEGIRD -= ButchChargeCount;
                                                            this.GameGoldChanged();// 更新灵符数量
                                                            m_UseGameGird = ButchChargeCount;// 灵符使用计数
                                                            if (M2Share.g_FunctionNPC != null)
                                                            {
                                                                M2Share.g_FunctionNPC.GotoLable(this, "@USEGAMEGIRD", false);// 灵符使用触发
                                                            }
                                                            break;
                                                    }
                                                    this.SendRefMsg(Grobal2.RM_MYSHOW, Grobal2.ET_OBJECTBUTCHMON, 0, 0, 0, "");// 挖尸体得到物品显示
                                                }
                                            }
                                        }
                                        break;
                                }
                            }
                        }
                        break;
                    case 122:// 121 狂热火蜥蜴
                        ButchChargeClass = ((TSalamanderATMonster)(BaseObject)).m_nButchChargeClass;
                        nCode = 54;
                        if (BaseObject.m_boDeath && (!BaseObject.m_boGhost) && (!BaseObject.m_boSkeleton) && (BaseObject.m_Master == null) && (BaseObject.m_btSlaveMakeLevel == 0))
                        {
                            nCode = 55;
                            ButchChargeCount = ((TSalamanderATMonster)(BaseObject)).m_nButchChargeCount;
                            switch (ButchChargeClass)
                            {
                                case 0:// 挖取身上装备收费模式,并减少人物相应的数值 金币模式
                                    if (this.m_nGold >= ButchChargeCount)
                                    {
                                        Butch = true;
                                    }
                                    else
                                    {
                                        this.SysMsg("您的金币没有达到" + (ButchChargeCount).ToString() + ",将挖取不到任何物品!", TMsgColor.c_Red, TMsgType.t_Hint);
                                    }
                                    break;
                                case 1:// 元宝模式
                                    if (m_nGameGold >= ButchChargeCount)
                                    {
                                        Butch = true;
                                    }
                                    else
                                    {
                                        this.SysMsg("您的" + M2Share.g_Config.sGameGoldName + "没有达到" + (ButchChargeCount).ToString() + ",将挖取不到任何物品!", TMsgColor.c_Red, TMsgType.t_Hint);
                                    }
                                    break;
                                case 2:// 金刚石模式
                                    if (m_nGAMEDIAMOND >= ButchChargeCount)
                                    {
                                        Butch = true;
                                    }
                                    else
                                    {
                                        this.SysMsg("您的" + M2Share.g_Config.sGameDiaMond + "没有达到" + (ButchChargeCount).ToString() + ",将挖取不到任何物品!", TMsgColor.c_Red, TMsgType.t_Hint);
                                    }
                                    break;
                                case 3:// 灵符模式
                                    if (m_nGAMEGIRD >= ButchChargeCount)
                                    {
                                        Butch = true;
                                    }
                                    else
                                    {
                                        this.SysMsg("您的" + M2Share.g_Config.sGameGird + "没有达到" + (ButchChargeCount).ToString() + ",将挖取不到任何物品!", TMsgColor.c_Red, TMsgType.t_Hint);
                                    }
                                    break;
                            }
                            nCode = 56;
                            if (Butch)
                            {
                                switch (HUtil32.Random(3))
                                {
                                    case 0:
                                        // 挖所需的条件达到
                                        // 随机处理挖
                                        // 挖取列表中的物品
                                        nCode = 57;
                                        if ((BaseObject != null))
                                        {
                                            if (BaseObject.m_boGhost)
                                            {
                                                return result;
                                            }
                                            if (BaseObject.m_boButchSkeleton)// 正在被挖尸体
                                            {
                                                return result;
                                            }
                                            BaseObject.m_boButchSkeleton = true;
                                            try
                                            {
                                                for (int i = ((TSalamanderATMonster)(BaseObject)).m_ButchItemList.Count - 1; i >= 0; i--)
                                                {
                                                    if (BaseObject.m_boGhost)
                                                    {
                                                        return result;
                                                    }
                                                    if (HUtil32.GetTickCount() - BaseObject.m_dwDeathTick > (M2Share.g_Config.dwMakeGhostPlayMosterTime - 2000))
                                                    {
                                                        return result;// 如果快要清理尸体时，则不再进入
                                                    }
                                                    if (((TSalamanderATMonster)(BaseObject)).m_ButchItemList.Count <= 0)
                                                    {
                                                        break;
                                                    }
                                                    MonItem = ((TMonItemInfo)(((TSalamanderATMonster)(BaseObject)).m_ButchItemList[i]));
                                                    if ((MonItem.ItemName).ToLower().CompareTo((M2Share.sSTRING_GOLDNAME).ToLower()) == 0)// 如果是金币
                                                    {
                                                        nCode = 58;
                                                        this.m_nGold = this.m_nGold + MonItem.Count;
                                                        if (MonItem.Count > 0)
                                                        {
                                                            if (M2Share.g_boGameLogGold)
                                                            {
                                                                M2Share.AddGameDataLog("37" + "\09" + this.m_sMapName + "\09" + (this.m_nCurrX).ToString()
                                                                    + "\09" + (this.m_nCurrY).ToString() + "\09" + this.m_sCharName + "\09" + M2Share.sSTRING_GOLDNAME
                                                                    + "\09" + (MonItem.Count).ToString() + "\09" + "1" + "\09" + BaseObject.m_sCharName);
                                                            }
                                                        }
                                                        this.GoldChanged();
                                                        if (BaseObject != null)
                                                        {
                                                            ((TSalamanderATMonster)(BaseObject)).m_ButchItemList.RemoveAt(i);
                                                        }
                                                        switch (ButchChargeClass)
                                                        {
                                                            case 0:// 挖到后,删除对应的物品 挖取到物品后减所需的条件的数量 金币模式
                                                                this.m_nGold -= ButchChargeCount;
                                                                this.GoldChanged();
                                                                break;
                                                            case 1://更新玩家的金币// 元宝模式
                                                                m_nGameGold -= ButchChargeCount;
                                                                this.GameGoldChanged();
                                                                break;
                                                            case 2:// 更新元宝数量 金刚石模式
                                                                m_nGAMEDIAMOND -= ButchChargeCount;
                                                                this.GameGoldChanged();
                                                                break;
                                                            case 3:// 更新金刚石数量 灵符模式
                                                                m_nGAMEGIRD -= ButchChargeCount;
                                                                this.GameGoldChanged();// 更新灵符数量 
                                                                m_UseGameGird = ButchChargeCount;//灵符使用计数
                                                                if (M2Share.g_FunctionNPC != null)
                                                                {
                                                                    M2Share.g_FunctionNPC.GotoLable(this, "@USEGAMEGIRD", false); // 灵符使用触发
                                                                }
                                                                break;
                                                        }
                                                        this.SendRefMsg(Grobal2.RM_MYSHOW, Grobal2.ET_OBJECTBUTCHMON, 0, 0, 0, "");// 挖尸体得到物品显示
                                                        break;
                                                    }
                                                    else
                                                    {
                                                        UserItem = new TUserItem();
                                                        if (M2Share.UserEngine.CopyToUserItemFromName(MonItem.ItemName, UserItem))
                                                        {
                                                            nCode = 59;
                                                            UserItem.Dura = (ushort)HUtil32.Round((double)(UserItem.DuraMax / 100) * (20 + HUtil32.Random(80)));
                                                            if (HUtil32.Random(M2Share.g_Config.nPlayMonRandomAddValue) == 0)
                                                            {
                                                                M2Share.UserEngine.RandomUpgradeItem(UserItem);
                                                            }
                                                            nCode = 60;
                                                            if ((UserItem != null))
                                                            {
                                                                nCode = 61;
                                                                switch (ButchChargeClass)
                                                                {
                                                                    case 0:// 挖取到物品后减所需的条件的数量// 金币模式
                                                                        this.m_nGold -= ButchChargeCount;
                                                                        this.GoldChanged();
                                                                        break;
                                                                    case 1:// 更新玩家的金币 元宝模式
                                                                        m_nGameGold -= ButchChargeCount;
                                                                        this.GameGoldChanged();
                                                                        break;
                                                                    case 2:// 更新元宝数量 金刚石模式
                                                                        m_nGAMEDIAMOND -= ButchChargeCount;
                                                                        this.GameGoldChanged();
                                                                        break;
                                                                    case 3:// 更新金刚石数量 灵符模式
                                                                        m_nGAMEGIRD -= ButchChargeCount;
                                                                        this.GameGoldChanged();// 更新灵符数量 
                                                                        m_UseGameGird = ButchChargeCount;//灵符使用计数
                                                                        if (M2Share.g_FunctionNPC != null)
                                                                        {
                                                                            M2Share.g_FunctionNPC.GotoLable(this, "@USEGAMEGIRD", false);// 灵符使用触发
                                                                        }
                                                                        break;
                                                                }
                                                                nCode = 62;
                                                                if (BaseObject != null)
                                                                {
                                                                    ((TSalamanderATMonster)(BaseObject)).m_ButchItemList.RemoveAt(i);// 挖到后,删除对应的物品
                                                                }
                                                                this.SendRefMsg(Grobal2.RM_MYSHOW, Grobal2.ET_OBJECTBUTCHMON, 0, 0, 0, "");// 挖尸体得到物品显示
                                                                sCheckItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                                                                this.PlugOfCheckCanItem(7, sCheckItemName, false, 0, 0);// 禁止物品规则(管理插件功能)
                                                                if (IsEnoughBag())  // 人物的包裹是否满了
                                                                {
                                                                    StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                                                    if (this.IsAddWeightAvailable(StdItem.Weight))  // 人物的负重没有超过
                                                                    {
                                                                        if (StdItem.NeedIdentify == 1)
                                                                        {
                                                                            M2Share.AddGameDataLog("37" + "\09" + this.m_sMapName + "\09" + (this.m_nCurrX).ToString()
                                                                                + "\09" + (this.m_nCurrY).ToString() + "\09" + this.m_sCharName + "\09" + StdItem.Name
                                                                                + "\09" + (UserItem.MakeIndex).ToString() + "\09" + "(" + (HUtil32.LoWord(StdItem.DC)).ToString()
                                                                                + "/" + (HUtil32.HiWord(StdItem.DC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MC)).ToString()
                                                                                + "/" + (HUtil32.HiWord(StdItem.MC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.SC)).ToString()
                                                                                + "/" + (HUtil32.HiWord(StdItem.SC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.AC)).ToString()
                                                                                + "/" + (HUtil32.HiWord(StdItem.AC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MAC)).ToString()
                                                                                + "/" + (HUtil32.HiWord(StdItem.MAC)).ToString() + ")" + (UserItem.btValue[0]).ToString() + "/"
                                                                                + (UserItem.btValue[1]).ToString() + "/" + (UserItem.btValue[2]).ToString() + "/"
                                                                                + (UserItem.btValue[3]).ToString() + "/" + (UserItem.btValue[4]).ToString() + "/"
                                                                                + (UserItem.btValue[5]).ToString() + "/" + (UserItem.btValue[6]).ToString() + "/"
                                                                                + (UserItem.btValue[7]).ToString() + "/" + (UserItem.btValue[8]).ToString() + "/"
                                                                                + (UserItem.btValue[14]).ToString() + "\09" + BaseObject.m_sCharName);
                                                                        }
                                                                        this.m_ItemList.Add(UserItem);
                                                                        nCode = 63;
                                                                        if (this.m_btRaceServer == Grobal2.RC_PLAYOBJECT)
                                                                        {
                                                                            nCode = 64;
                                                                            SendAddItem(UserItem); // 一次只给玩家一件物品
                                                                            SendUpdateItem(UserItem);// 更新物品
                                                                        }
                                                                        break;
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    nCode = 65;
                                                                    this.DropItemDown(UserItem, 3, false, false, this, this); // 一次只给玩家一件物品
                                                                    this.SysMsg(GameMsgDef.sButchEnoughBagHintMsg, TMsgColor.c_Red, TMsgType.t_Hint);// '您的包裹已没有办法装下任何物品!'
                                                                    break;
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                           UserItem=null;
                                                        }
                                                    }
                                                }
                                            }
                                            finally
                                            {
                                                BaseObject.m_boButchSkeleton = false;
                                            }
                                        }
                                        break;
                                    case 1:
                                    case 2:// 进入触发段
                                        if (!IsEnoughBag())// '您的包裹已没有办法装下任何物品!'
                                        {
                                            this.SysMsg(GameMsgDef.sButchEnoughBagHintMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                                        }
                                        if ((M2Share.g_FunctionNPC != null) && ((TSalamanderATMonster)(BaseObject)).boIntoTrigger && IsEnoughBag())
                                        {
                                            if (M2Share.g_FunctionNPC.m_boGotoCount < 80)// 防止Goto数量过多,引起M2挂死
                                            {
                                                nItemCount = (byte)this.m_ItemList.Count;// 进入触发段前的包裹物品数量 
                                                nLevel = this.m_Abil.Level;// 进入触发段前的等级 
                                                nExp = this.m_Abil.Exp;// 进入触发段前的经验 
                                                nGameDiamond = m_nGAMEDIAMOND;// 进入触发段前的金刚石 
                                                nCreditPoint = m_btCreditPoint;// 进入触发段前的声望 
                                                nGameGird = m_nGAMEGIRD;// 进入触发段前的灵符 
                                                M2Share.g_FunctionNPC.GotoLable(this, "@ButchCloneItem" + BaseObject.m_sCharName, false);
                                                if ((nItemCount < this.m_ItemList.Count) || ((nExp < this.m_Abil.Exp) && (nLevel == this.m_Abil.Level)) || ((nExp > this.m_Abil.Exp) && (nLevel < this.m_Abil.Level)) || (nGameDiamond < m_nGAMEDIAMOND) || (nCreditPoint < m_btCreditPoint) || (nGameGird < m_nGAMEGIRD))
                                                {
                                                    switch (ButchChargeClass)
                                                    {
                                                        case 0:// 挖取到物品后减所需的条件的数量 金币模式
                                                            this.m_nGold -= ButchChargeCount;
                                                            this.GoldChanged();
                                                            break;
                                                        case 1:// 更新玩家的金币 元宝模式
                                                            m_nGameGold -= ButchChargeCount;
                                                            this.GameGoldChanged();
                                                            break;
                                                        case 2:// 更新元宝数量 金刚石模式
                                                            m_nGAMEDIAMOND -= ButchChargeCount;
                                                            this.GameGoldChanged();
                                                            break;
                                                        case 3:// 更新金刚石数量 灵符模式
                                                            m_nGAMEGIRD -= ButchChargeCount;
                                                            this.GameGoldChanged();// 更新灵符数量 
                                                            m_UseGameGird = ButchChargeCount;//灵符使用计数
                                                            if (M2Share.g_FunctionNPC != null)// 灵符使用触发
                                                            {
                                                                M2Share.g_FunctionNPC.GotoLable(this, "@USEGAMEGIRD", false);
                                                            }
                                                            break;
                                                    }
                                                    this.SendRefMsg(Grobal2.RM_MYSHOW, Grobal2.ET_OBJECTBUTCHMON, 0, 0, 0, "");// 挖尸体得到物品显示
                                                }
                                            }
                                        }
                                        break;
                                }
                            }
                        }
                        break;
                    case 123://122 圣殿卫士
                        ButchChargeClass = ((TTempleGuardian)(BaseObject)).m_nButchChargeClass;
                        nCode = 66;
                        if (BaseObject.m_boDeath && (!BaseObject.m_boGhost) && (!BaseObject.m_boSkeleton) && (BaseObject.m_Master == null) && (BaseObject.m_btSlaveMakeLevel == 0))
                        {
                            nCode = 67;
                            ButchChargeCount = ((TTempleGuardian)(BaseObject)).m_nButchChargeCount;
                            switch (ButchChargeClass)
                            {
                                case 0:// 挖取身上装备收费模式,并减少人物相应的数值// 金币模式
                                    if (this.m_nGold >= ButchChargeCount)
                                    {
                                        Butch = true;
                                    }
                                    else
                                    {
                                        this.SysMsg("您的金币没有达到" + (ButchChargeCount).ToString() + ",将挖取不到任何物品!", TMsgColor.c_Red, TMsgType.t_Hint);
                                    }
                                    break;
                                case 1:// 元宝模式
                                    if (m_nGameGold >= ButchChargeCount)
                                    {
                                        Butch = true;
                                    }
                                    else
                                    {
                                        this.SysMsg("您的" + M2Share.g_Config.sGameGoldName + "没有达到" + (ButchChargeCount).ToString() + ",将挖取不到任何物品!", TMsgColor.c_Red, TMsgType.t_Hint);
                                    }
                                    break;
                                case 2:// 金刚石模式
                                    if (m_nGAMEDIAMOND >= ButchChargeCount)
                                    {
                                        Butch = true;
                                    }
                                    else
                                    {
                                        this.SysMsg("您的" + M2Share.g_Config.sGameDiaMond + "没有达到" + (ButchChargeCount).ToString() + ",将挖取不到任何物品!", TMsgColor.c_Red, TMsgType.t_Hint);
                                    }
                                    break;
                                case 3:// 灵符模式
                                    if (m_nGAMEGIRD >= ButchChargeCount)
                                    {
                                        Butch = true;
                                    }
                                    else
                                    {
                                        this.SysMsg("您的" + M2Share.g_Config.sGameGird + "没有达到" + (ButchChargeCount).ToString() + ",将挖取不到任何物品!", TMsgColor.c_Red, TMsgType.t_Hint);
                                    }
                                    break;
                            }
                            nCode = 68;
                            if (Butch)
                            {
                                switch (HUtil32.Random(3))
                                {
                                    case 0:// 挖所需的条件达到 随机处理挖 挖取列表中的物品
                                        nCode = 69;
                                        if ((BaseObject != null))
                                        {
                                            if (BaseObject.m_boGhost)
                                            {
                                                return result;
                                            }
                                            if (BaseObject.m_boButchSkeleton)// 正在被挖尸体
                                            {
                                                return result;
                                            }
                                            BaseObject.m_boButchSkeleton = true;
                                            try
                                            {
                                                for (int i = ((TTempleGuardian)(BaseObject)).m_ButchItemList.Count - 1; i >= 0; i--)
                                                {
                                                    if (BaseObject.m_boGhost)
                                                    {
                                                        return result;
                                                    }
                                                    if (HUtil32.GetTickCount() - BaseObject.m_dwDeathTick > (M2Share.g_Config.dwMakeGhostPlayMosterTime - 2000))
                                                    {
                                                        return result;// 如果快要清理尸体时，则不再进入
                                                    }
                                                    if (((TTempleGuardian)(BaseObject)).m_ButchItemList.Count <= 0)
                                                    {
                                                        break;
                                                    }
                                                    MonItem = ((TMonItemInfo)(((TTempleGuardian)(BaseObject)).m_ButchItemList[i]));
                                                    if ((MonItem.ItemName).ToLower().CompareTo((M2Share.sSTRING_GOLDNAME).ToLower()) == 0) // 如果是金币
                                                    {
                                                        nCode = 70;
                                                        this.m_nGold = this.m_nGold + MonItem.Count;
                                                        if (MonItem.Count > 0)
                                                        {
                                                            if (M2Share.g_boGameLogGold)
                                                            {
                                                                M2Share.AddGameDataLog("37" + "\09" + this.m_sMapName + "\09" + (this.m_nCurrX).ToString()
                                                                    + "\09" + (this.m_nCurrY).ToString() + "\09" + this.m_sCharName + "\09" + M2Share.sSTRING_GOLDNAME
                                                                    + "\09" + (MonItem.Count).ToString() + "\09" + "1" + "\09" + BaseObject.m_sCharName);
                                                            }
                                                        }
                                                        this.GoldChanged();
                                                        if (BaseObject != null)
                                                        {
                                                            ((TTempleGuardian)(BaseObject)).m_ButchItemList.RemoveAt(i);
                                                        }
                                                        switch (ButchChargeClass)
                                                        {
                                                            case 0:// 挖到后,删除对应的物品 挖取到物品后减所需的条件的数量 金币模式
                                                                this.m_nGold -= ButchChargeCount;
                                                                this.GoldChanged();
                                                                break;
                                                            case 1:// 更新玩家的金币 元宝模式
                                                                m_nGameGold -= ButchChargeCount;
                                                                this.GameGoldChanged();
                                                                break;
                                                            case 2:// 更新元宝数量 金刚石模式
                                                                m_nGAMEDIAMOND -= ButchChargeCount;
                                                                this.GameGoldChanged();
                                                                break;
                                                            case 3:// 更新金刚石数量 灵符模式
                                                                m_nGAMEGIRD -= ButchChargeCount;
                                                                this.GameGoldChanged();// 更新灵符数量
                                                                m_UseGameGird = ButchChargeCount;// 灵符使用计数
                                                                if (M2Share.g_FunctionNPC != null)
                                                                {
                                                                    M2Share.g_FunctionNPC.GotoLable(this, "@USEGAMEGIRD", false); // 灵符使用触发 
                                                                }
                                                                break;
                                                        }
                                                        this.SendRefMsg(Grobal2.RM_MYSHOW, Grobal2.ET_OBJECTBUTCHMON, 0, 0, 0, "");// 挖尸体得到物品显示
                                                        break;
                                                    }
                                                    else
                                                    {
                                                        UserItem = new TUserItem();
                                                        if (M2Share.UserEngine.CopyToUserItemFromName(MonItem.ItemName, UserItem))
                                                        {
                                                            nCode = 71;
                                                            UserItem.Dura = (ushort)HUtil32.Round((double)(UserItem.DuraMax / 100) * (20 + HUtil32.Random(80)));
                                                            if (HUtil32.Random(M2Share.g_Config.nPlayMonRandomAddValue) == 0)
                                                            {
                                                                M2Share.UserEngine.RandomUpgradeItem(UserItem);
                                                            }
                                                            nCode = 72;
                                                            if ((UserItem != null))
                                                            {
                                                                nCode = 73;
                                                                switch (ButchChargeClass)
                                                                {
                                                                    case 0:// 挖取到物品后减所需的条件的数量 金币模式
                                                                        this.m_nGold -= ButchChargeCount;
                                                                        this.GoldChanged();
                                                                        break;
                                                                    case 1://更新玩家的金币 元宝模式
                                                                        m_nGameGold -= ButchChargeCount;
                                                                        this.GameGoldChanged();
                                                                        break;
                                                                    case 2:// 更新元宝数量  金刚石模式
                                                                        m_nGAMEDIAMOND -= ButchChargeCount;
                                                                        this.GameGoldChanged();
                                                                        break;
                                                                    case 3:// 更新金刚石数量 灵符模式
                                                                        m_nGAMEGIRD -= ButchChargeCount;
                                                                        this.GameGoldChanged();// 更新灵符数量
                                                                        m_UseGameGird = ButchChargeCount;// 灵符使用计数
                                                                        if (M2Share.g_FunctionNPC != null)
                                                                        {
                                                                            // 灵符使用触发 20090108
                                                                            M2Share.g_FunctionNPC.GotoLable(this, "@USEGAMEGIRD", false);
                                                                        }
                                                                        break;
                                                                }
                                                                nCode = 74;
                                                                if (BaseObject != null)
                                                                {
                                                                    ((TTempleGuardian)(BaseObject)).m_ButchItemList.RemoveAt(i); // 挖到后,删除对应的物品
                                                                }
                                                                this.SendRefMsg(Grobal2.RM_MYSHOW, Grobal2.ET_OBJECTBUTCHMON, 0, 0, 0, "");// 挖尸体得到物品显示
                                                                sCheckItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                                                                this.PlugOfCheckCanItem(7, sCheckItemName, false, 0, 0);// 禁止物品规则(管理插件功能)
                                                                if (IsEnoughBag()) // 人物的包裹是否满了
                                                                {

                                                                    StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                                                    if (this.IsAddWeightAvailable(StdItem.Weight))
                                                                    {
                                                                        // 人物的负重没有超过
                                                                        if (StdItem.NeedIdentify == 1)
                                                                        {
                                                                            M2Share.AddGameDataLog("37" + "\09" + this.m_sMapName + "\09" + (this.m_nCurrX).ToString() + "\09" + (this.m_nCurrY).ToString() + "\09" + this.m_sCharName + "\09" + StdItem.Name + "\09" + (UserItem.MakeIndex).ToString() + "\09" + "(" + (HUtil32.LoWord(StdItem.DC)).ToString() + "/" + (HUtil32.HiWord(StdItem.DC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MC)).ToString() + "/" + (HUtil32.HiWord(StdItem.MC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.SC)).ToString() + "/" + (HUtil32.HiWord(StdItem.SC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.AC)).ToString() + "/" + (HUtil32.HiWord(StdItem.AC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MAC)).ToString() + "/" + (HUtil32.HiWord(StdItem.MAC)).ToString() + ")" + (UserItem.btValue[0]).ToString() + "/" + (UserItem.btValue[1]).ToString() + "/" + (UserItem.btValue[2]).ToString() + "/" + (UserItem.btValue[3]).ToString() + "/" + (UserItem.btValue[4]).ToString() + "/" + (UserItem.btValue[5]).ToString() + "/" + (UserItem.btValue[6]).ToString() + "/" + (UserItem.btValue[7]).ToString() + "/" + (UserItem.btValue[8]).ToString() + "/" + (UserItem.btValue[14]).ToString() + "\09" + BaseObject.m_sCharName);
                                                                        }
                                                                        this.m_ItemList.Add(UserItem);
                                                                        nCode = 75;
                                                                        if (this.m_btRaceServer == Grobal2.RC_PLAYOBJECT)
                                                                        {
                                                                            nCode = 76;
                                                                            SendAddItem(UserItem);
                                                                            SendUpdateItem(UserItem);
                                                                            // 更新物品
                                                                        }
                                                                        break;
                                                                        // 一次只给玩家一件物品 20080121
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    nCode = 77;
                                                                    this.DropItemDown(UserItem, 3, false, false, this, this);
                                                                    // 20080610
                                                                    // '您的包裹已没有办法装下任何物品!'
                                                                    this.SysMsg(GameMsgDef.sButchEnoughBagHintMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                                                                    break;
                                                                    // 一次只给玩家一件物品 20080121
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                            //Dispose(UserItem);
                                                            UserItem = null;
                                                        }
                                                        // if CopyToUserItemFromName(MonItem.ItemName, UserItem) then begin
                                                    }
                                                    // if TTempleGuardian(BaseObject).m_ButchItemList.count = 0 then SysMsg(sYouFoundNothing {未发现任何物品！！！}, c_Red, t_Hint);
                                                }
                                                // for i := TTempleGuardian(BaseObject).m_ItemList.count-1 downto 0 do begin
                                            }
                                            finally
                                            {
                                                BaseObject.m_boButchSkeleton = false;
                                            }
                                        }
                                        break;
                                    case 1:
                                    case 2:// 进入触发段
                                        if (!IsEnoughBag())
                                        {
                                            this.SysMsg(GameMsgDef.sButchEnoughBagHintMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                                        }
                                        if ((M2Share.g_FunctionNPC != null) && ((TTempleGuardian)(BaseObject)).boIntoTrigger && IsEnoughBag())
                                        {
                                            if (M2Share.g_FunctionNPC.m_boGotoCount < 80) // 防止Goto数量过多,引起M2挂死 20081004
                                            {
                                                nItemCount = (byte)this.m_ItemList.Count;// 进入触发段前的包裹物品数量 20080925
                                                nLevel = this.m_Abil.Level;// 进入触发段前的等级 20081018
                                                nExp = this.m_Abil.Exp;// 进入触发段前的经验 20081018
                                                nGameDiamond = m_nGAMEDIAMOND;// 进入触发段前的金刚石 20081018
                                                nCreditPoint = m_btCreditPoint;// 进入触发段前的声望 20081018
                                                nGameGird = m_nGAMEGIRD;// 进入触发段前的灵符 20081018
                                                M2Share.g_FunctionNPC.GotoLable(this, "@ButchCloneItem" + BaseObject.m_sCharName, false);
                                                if ((nItemCount < this.m_ItemList.Count) || ((nExp < this.m_Abil.Exp) && (nLevel == this.m_Abil.Level)) || ((nExp > this.m_Abil.Exp) && (nLevel < this.m_Abil.Level)) || (nGameDiamond < m_nGAMEDIAMOND) || (nCreditPoint < m_btCreditPoint) || (nGameGird < m_nGAMEGIRD))
                                                {
                                                    switch (ButchChargeClass)
                                                    {
                                                        case 0:
                                                            // 挖取到物品后减所需的条件的数量 20080503
                                                            // 金币模式
                                                            this.m_nGold -= ButchChargeCount;
                                                            this.GoldChanged();
                                                            break;
                                                        case 1:
                                                            // 20080414 更新玩家的金币
                                                            // 元宝模式
                                                            m_nGameGold -= ButchChargeCount;
                                                            this.GameGoldChanged();
                                                            break;
                                                        case 2:
                                                            // 更新元宝数量  20080414
                                                            // 金刚石模式
                                                            m_nGAMEDIAMOND -= ButchChargeCount;
                                                            this.GameGoldChanged();
                                                            break;
                                                        case 3:// 更新金刚石数量  灵符模式
                                                            m_nGAMEGIRD -= ButchChargeCount;
                                                            this.GameGoldChanged();// 更新灵符数量
                                                            m_UseGameGird = ButchChargeCount;//灵符使用计数
                                                            if (M2Share.g_FunctionNPC != null)
                                                            {
                                                                M2Share.g_FunctionNPC.GotoLable(this, "@USEGAMEGIRD", false); // 灵符使用触发
                                                            }
                                                            break;
                                                    }
                                                    this.SendRefMsg(Grobal2.RM_MYSHOW, Grobal2.ET_OBJECTBUTCHMON, 0, 0, 0, "");// 挖尸体得到物品显示
                                                }
                                            }
                                        }
                                        break;
                                }
                            }
                        }
                        break;
                    case 124:// 金杖蜘蛛
                        ButchChargeClass = ((TheCrutchesSpider)(BaseObject)).m_nButchChargeClass;
                        nCode = 78;
                        if (BaseObject.m_boDeath && (!BaseObject.m_boGhost) && (!BaseObject.m_boSkeleton) && (BaseObject.m_Master == null) && (BaseObject.m_btSlaveMakeLevel == 0))
                        {
                            nCode = 79;
                            ButchChargeCount = ((TheCrutchesSpider)(BaseObject)).m_nButchChargeCount;
                            switch (ButchChargeClass)
                            {
                                case 0:// 挖取身上装备收费模式,并减少人物相应的数值 金币模式
                                    if (this.m_nGold >= ButchChargeCount)
                                    {
                                        Butch = true;
                                    }
                                    else
                                    {
                                        this.SysMsg("您的金币没有达到" + (ButchChargeCount).ToString() + ",将挖取不到任何物品!", TMsgColor.c_Red, TMsgType.t_Hint);
                                    }
                                    break;
                                case 1:// 元宝模式
                                    if (m_nGameGold >= ButchChargeCount)
                                    {
                                        Butch = true;
                                    }
                                    else
                                    {
                                        this.SysMsg("您的" + M2Share.g_Config.sGameGoldName + "没有达到" + (ButchChargeCount).ToString() + ",将挖取不到任何物品!", TMsgColor.c_Red, TMsgType.t_Hint);
                                    }
                                    break;
                                case 2:// 金刚石模式
                                    if (m_nGAMEDIAMOND >= ButchChargeCount)
                                    {
                                        Butch = true;
                                    }
                                    else
                                    {
                                        this.SysMsg("您的" + M2Share.g_Config.sGameDiaMond + "没有达到" + (ButchChargeCount).ToString() + ",将挖取不到任何物品!", TMsgColor.c_Red, TMsgType.t_Hint);
                                    }
                                    break;
                                case 3:// 灵符模式
                                    if (m_nGAMEGIRD >= ButchChargeCount)
                                    {
                                        Butch = true;
                                    }
                                    else
                                    {
                                        this.SysMsg("您的" + M2Share.g_Config.sGameGird + "没有达到" + (ButchChargeCount).ToString() + ",将挖取不到任何物品!", TMsgColor.c_Red, TMsgType.t_Hint);
                                    }
                                    break;
                            }
                            nCode = 80;
                            if (Butch)
                            {
                                switch (HUtil32.Random(3))
                                {
                                    case 0:// 挖所需的条件达到 随机处理挖 挖取列表中的物品
                                        nCode = 81;
                                        if ((BaseObject != null))
                                        {
                                            if (BaseObject.m_boGhost)
                                            {
                                                return result;
                                            }
                                            if (BaseObject.m_boButchSkeleton) // 正在被挖尸体
                                            {
                                                return result;
                                            }
                                            BaseObject.m_boButchSkeleton = true;
                                            try
                                            {
                                                for (int i = ((TheCrutchesSpider)(BaseObject)).m_ButchItemList.Count - 1; i >= 0; i--)
                                                {
                                                    if (BaseObject.m_boGhost)
                                                    {
                                                        return result;
                                                    }
                                                    if (HUtil32.GetTickCount() - BaseObject.m_dwDeathTick > (M2Share.g_Config.dwMakeGhostPlayMosterTime - 2000)) // 如果快要清理尸体时，则不再进入
                                                    {
                                                        return result;
                                                    }
                                                    if (((TheCrutchesSpider)(BaseObject)).m_ButchItemList.Count <= 0)
                                                    {
                                                        break;
                                                    }
                                                    MonItem = ((TMonItemInfo)(((TheCrutchesSpider)(BaseObject)).m_ButchItemList[i]));
                                                    if ((MonItem.ItemName).ToLower().CompareTo((M2Share.sSTRING_GOLDNAME).ToLower()) == 0)
                                                    {
                                                        // 如果是金币
                                                        nCode = 82;
                                                        this.m_nGold = this.m_nGold + MonItem.Count;
                                                        if (MonItem.Count > 0)
                                                        {
                                                            if (M2Share.g_boGameLogGold)
                                                            {
                                                                M2Share.AddGameDataLog("37" + "\09" + this.m_sMapName + "\09" + (this.m_nCurrX).ToString() + "\09" + (this.m_nCurrY).ToString() + "\09" + this.m_sCharName + "\09" + M2Share.sSTRING_GOLDNAME + "\09" + (MonItem.Count).ToString() + "\09" + "1" + "\09" + BaseObject.m_sCharName);
                                                            }
                                                        }
                                                        this.GoldChanged();
                                                        if (BaseObject != null)
                                                        {
                                                            ((TheCrutchesSpider)(BaseObject)).m_ButchItemList.RemoveAt(i);
                                                        }
                                                        switch (ButchChargeClass)
                                                        {
                                                            case 0:
                                                                // 挖到后,删除对应的物品
                                                                // 挖取到物品后减所需的条件的数量 20080503
                                                                // 金币模式
                                                                this.m_nGold -= ButchChargeCount;
                                                                this.GoldChanged();
                                                                break;
                                                            case 1:
                                                                // 20080414 更新玩家的金币
                                                                // 元宝模式
                                                                m_nGameGold -= ButchChargeCount;
                                                                this.GameGoldChanged();
                                                                break;
                                                            case 2:
                                                                // 更新元宝数量  20080414
                                                                // 金刚石模式
                                                                m_nGAMEDIAMOND -= ButchChargeCount;
                                                                this.GameGoldChanged();
                                                                break;
                                                            case 3:
                                                                // 更新金刚石数量 20080414
                                                                // 灵符模式
                                                                m_nGAMEGIRD -= ButchChargeCount;
                                                                this.GameGoldChanged();
                                                                // 更新灵符数量 20080414
                                                                m_UseGameGird = ButchChargeCount;
                                                                // 20090108 灵符使用计数
                                                                if (M2Share.g_FunctionNPC != null)
                                                                {
                                                                    // 灵符使用触发 20090108
                                                                    M2Share.g_FunctionNPC.GotoLable(this, "@USEGAMEGIRD", false);
                                                                }
                                                                break;
                                                        }
                                                        // Case
                                                        this.SendRefMsg(Grobal2.RM_MYSHOW, Grobal2.ET_OBJECTBUTCHMON, 0, 0, 0, "");
                                                        // 挖尸体得到物品显示
                                                        break;
                                                    }
                                                    else
                                                    {
                                                        UserItem = new TUserItem();
                                                        if (M2Share.UserEngine.CopyToUserItemFromName(MonItem.ItemName, UserItem))
                                                        {
                                                            nCode = 83;
                                                            //UserItem.Dura = Convert.ToUInt16(HUtil32.Round((UserItem.DuraMax / 100) * (20 + HUtil32.Random(80))));
                                                            if (HUtil32.Random(M2Share.g_Config.nPlayMonRandomAddValue) == 0)
                                                            {
                                                                M2Share.UserEngine.RandomUpgradeItem(UserItem);
                                                            }
                                                            nCode = 84;
                                                            if ((UserItem != null))
                                                            {
                                                                nCode = 85;
                                                                switch (ButchChargeClass)
                                                                {
                                                                    case 0:
                                                                        // 挖取到物品后减所需的条件的数量 20080503
                                                                        // 金币模式
                                                                        this.m_nGold -= ButchChargeCount;
                                                                        this.GoldChanged();
                                                                        break;
                                                                    case 1:
                                                                        // 20080414 更新玩家的金币
                                                                        // 元宝模式
                                                                        m_nGameGold -= ButchChargeCount;
                                                                        this.GameGoldChanged();
                                                                        break;
                                                                    case 2:
                                                                        // 更新元宝数量  20080414
                                                                        // 金刚石模式
                                                                        m_nGAMEDIAMOND -= ButchChargeCount;
                                                                        this.GameGoldChanged();
                                                                        break;
                                                                    case 3:
                                                                        // 更新金刚石数量 20080414
                                                                        // 灵符模式
                                                                        m_nGAMEGIRD -= ButchChargeCount;
                                                                        this.GameGoldChanged();
                                                                        // 更新灵符数量 20080414
                                                                        m_UseGameGird = ButchChargeCount;
                                                                        // 20090108 灵符使用计数
                                                                        if (M2Share.g_FunctionNPC != null)
                                                                        {
                                                                            // 灵符使用触发 20090108
                                                                            M2Share.g_FunctionNPC.GotoLable(this, "@USEGAMEGIRD", false);
                                                                        }
                                                                        break;
                                                                }
                                                                // Case
                                                                nCode = 86;
                                                                if (BaseObject != null)
                                                                {
                                                                    ((TheCrutchesSpider)(BaseObject)).m_ButchItemList.RemoveAt(i);
                                                                }
                                                                // 挖到后,删除对应的物品
                                                                this.SendRefMsg(Grobal2.RM_MYSHOW, Grobal2.ET_OBJECTBUTCHMON, 0, 0, 0, "");
                                                                // 挖尸体得到物品显示 20080325
                                                                sCheckItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                                                                this.PlugOfCheckCanItem(7, sCheckItemName, false, 0, 0);
                                                                // 禁止物品规则(管理插件功能) 20080729
                                                                if (IsEnoughBag())
                                                                {
                                                                    // 人物的包裹是否满了 20080414
                                                                    StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                                                    if (this.IsAddWeightAvailable(StdItem.Weight))
                                                                    {
                                                                        // 人物的负重没有超过
                                                                        if (StdItem.NeedIdentify == 1)
                                                                        {
                                                                            M2Share.AddGameDataLog("37" + "\09" + this.m_sMapName + "\09" + (this.m_nCurrX).ToString() + "\09" +
                                                                                (this.m_nCurrY).ToString() + "\09" + this.m_sCharName + "\09" + StdItem.Name + "\09" + (UserItem.MakeIndex).ToString()
                                                                                + "\09" + "(" + (HUtil32.LoWord(StdItem.DC)).ToString() + "/" + (HUtil32.HiWord(StdItem.DC)).ToString() + ")" + "("
                                                                                + (HUtil32.LoWord(StdItem.MC)).ToString() + "/" + (HUtil32.HiWord(StdItem.MC)).ToString() + ")"
                                                                                + "(" + (HUtil32.LoWord(StdItem.SC)).ToString() + "/" + (HUtil32.HiWord(StdItem.SC)).ToString() + ")"
                                                                                + "(" + (HUtil32.LoWord(StdItem.AC)).ToString() + "/" + (HUtil32.HiWord(StdItem.AC)).ToString() + ")"
                                                                                + "(" + (HUtil32.LoWord(StdItem.MAC)).ToString() + "/" + (HUtil32.HiWord(StdItem.MAC)).ToString() + ")"
                                                                                + (UserItem.btValue[0]).ToString() + "/" + (UserItem.btValue[1]).ToString() + "/" + (UserItem.btValue[2]).ToString()
                                                                                + "/" + (UserItem.btValue[3]).ToString() + "/" + (UserItem.btValue[4]).ToString() + "/" + (UserItem.btValue[5]).ToString()
                                                                                + "/" + (UserItem.btValue[6]).ToString() + "/" + (UserItem.btValue[7]).ToString() + "/" + (UserItem.btValue[8]).ToString()
                                                                                + "/" + (UserItem.btValue[14]).ToString() + "\09" + BaseObject.m_sCharName);
                                                                        }
                                                                        this.m_ItemList.Add(UserItem);
                                                                        nCode = 87;
                                                                        if (this.m_btRaceServer == Grobal2.RC_PLAYOBJECT)
                                                                        {
                                                                            nCode = 88;
                                                                            SendAddItem(UserItem);
                                                                            SendUpdateItem(UserItem);
                                                                            // 更新物品
                                                                        }
                                                                        break;
                                                                        // 一次只给玩家一件物品 20080121
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    nCode = 89;
                                                                    this.DropItemDown(UserItem, 3, false, false, this, this);
                                                                    // 20080610
                                                                    // '您的包裹已没有办法装下任何物品!'
                                                                    this.SysMsg(GameMsgDef.sButchEnoughBagHintMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                                                                    break;
                                                                    // 一次只给玩家一件物品 20080121
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                            //Dispose(UserItem);
                                                            UserItem = null;
                                                        }
                                                        // if CopyToUserItemFromName(MonItem.ItemName, UserItem) then begin
                                                    }
                                                    // if TheCrutchesSpider(BaseObject).m_ButchItemList.count = 0 then SysMsg(sYouFoundNothing {未发现任何物品！！！}, c_Red, t_Hint);
                                                }
                                                // for i := TheCrutchesSpider(BaseObject).m_ItemList.count-1 downto 0 do begin
                                            }
                                            finally
                                            {
                                                BaseObject.m_boButchSkeleton = false;
                                            }
                                        }
                                        break;
                                    case 1:
                                    case 2:
                                        // 0
                                        // 进入触发段
                                        if (!IsEnoughBag())
                                        {
                                            // '您的包裹已没有办法装下任何物品!'
                                            this.SysMsg(GameMsgDef.sButchEnoughBagHintMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                                        }

                                        if ((M2Share.g_FunctionNPC != null) && ((TheCrutchesSpider)(BaseObject)).boIntoTrigger && IsEnoughBag())
                                        {
                                            // 20080716
                                            if (M2Share.g_FunctionNPC.m_boGotoCount < 80)
                                            {
                                                // 防止Goto数量过多,引起M2挂死 20081004
                                                nItemCount = (byte)this.m_ItemList.Count;
                                                // 进入触发段前的包裹物品数量 20080925
                                                nLevel = this.m_Abil.Level;
                                                // 进入触发段前的等级 20081018
                                                nExp = this.m_Abil.Exp;
                                                // 进入触发段前的经验 20081018
                                                nGameDiamond = m_nGAMEDIAMOND;
                                                // 进入触发段前的金刚石 20081018
                                                nCreditPoint = m_btCreditPoint;
                                                // 进入触发段前的声望 20081018
                                                nGameGird = m_nGAMEGIRD;
                                                // 进入触发段前的灵符 20081018
                                                M2Share.g_FunctionNPC.GotoLable(this, "@ButchCloneItem" + BaseObject.m_sCharName, false);
                                                if ((nItemCount < this.m_ItemList.Count) || ((nExp < this.m_Abil.Exp) && (nLevel == this.m_Abil.Level)) || ((nExp > this.m_Abil.Exp) && (nLevel < this.m_Abil.Level)) || (nGameDiamond < m_nGAMEDIAMOND) || (nCreditPoint < m_btCreditPoint) || (nGameGird < m_nGAMEGIRD))
                                                {
                                                    switch (ButchChargeClass)
                                                    {
                                                        case 0:
                                                            // 挖取到物品后减所需的条件的数量 20080503
                                                            // 金币模式
                                                            this.m_nGold -= ButchChargeCount;
                                                            this.GoldChanged();
                                                            break;
                                                        case 1:
                                                            // 20080414 更新玩家的金币
                                                            // 元宝模式
                                                            m_nGameGold -= ButchChargeCount;
                                                            this.GameGoldChanged();
                                                            break;
                                                        case 2:
                                                            // 更新元宝数量  20080414
                                                            // 金刚石模式
                                                            m_nGAMEDIAMOND -= ButchChargeCount;
                                                            this.GameGoldChanged();
                                                            break;
                                                        case 3:
                                                            // 更新金刚石数量 20080414
                                                            // 灵符模式
                                                            m_nGAMEGIRD -= ButchChargeCount;
                                                            this.GameGoldChanged();
                                                            // 更新灵符数量 20080414
                                                            m_UseGameGird = ButchChargeCount;
                                                            // 20090108 灵符使用计数
                                                            if (M2Share.g_FunctionNPC != null)
                                                            {
                                                                // 灵符使用触发 20090108
                                                                M2Share.g_FunctionNPC.GotoLable(this, "@USEGAMEGIRD", false);
                                                            }
                                                            break;
                                                    }
                                                    // Case
                                                    this.SendRefMsg(Grobal2.RM_MYSHOW, Grobal2.ET_OBJECTBUTCHMON, 0, 0, 0, "");
                                                    // 挖尸体得到物品显示 20080607
                                                }
                                            }
                                        }
                                        break;
                                        // 1
                                }
                                // case Random(2)
                            }
                            // if Butch then
                        }
                        break;
                    case 125:
                        // if BaseObject.m_boDeath
                        // 124
                        // 雷炎蛛王 20080811

                        ButchChargeClass = ((TYanLeiWangSpider)(BaseObject)).m_nButchChargeClass;
                        nCode = 90;
                        // and (BaseObject.m_btSlaveExpLevel = 0)
                        if (BaseObject.m_boDeath && (!BaseObject.m_boGhost) && (!BaseObject.m_boSkeleton) && (BaseObject.m_Master == null) && (BaseObject.m_btSlaveMakeLevel == 0))
                        {
                            nCode = 91;

                            ButchChargeCount = ((TYanLeiWangSpider)(BaseObject)).m_nButchChargeCount;
                            switch (ButchChargeClass)
                            {
                                case 0:
                                    // 挖取身上装备收费模式,并减少人物相应的数值
                                    // 金币模式
                                    if (this.m_nGold >= ButchChargeCount)
                                    {
                                        Butch = true;
                                    }
                                    else
                                    {
                                        this.SysMsg("您的金币没有达到" + (ButchChargeCount).ToString() + ",将挖取不到任何物品!", TMsgColor.c_Red, TMsgType.t_Hint);
                                    }
                                    break;
                                case 1:
                                    // 元宝模式
                                    if (m_nGameGold >= ButchChargeCount)
                                    {
                                        Butch = true;
                                    }
                                    else
                                    {
                                        this.SysMsg("您的" + M2Share.g_Config.sGameGoldName + "没有达到" + (ButchChargeCount).ToString() + ",将挖取不到任何物品!", TMsgColor.c_Red, TMsgType.t_Hint);
                                    }
                                    break;
                                case 2:
                                    // 金刚石模式
                                    if (m_nGAMEDIAMOND >= ButchChargeCount)
                                    {
                                        Butch = true;
                                    }
                                    else
                                    {
                                        this.SysMsg("您的" + M2Share.g_Config.sGameDiaMond + "没有达到" + (ButchChargeCount).ToString() + ",将挖取不到任何物品!", TMsgColor.c_Red, TMsgType.t_Hint);
                                    }
                                    break;
                                case 3:
                                    // 灵符模式
                                    if (m_nGAMEGIRD >= ButchChargeCount)
                                    {
                                        Butch = true;
                                    }
                                    else
                                    {
                                        this.SysMsg("您的" + M2Share.g_Config.sGameGird + "没有达到" + ButchChargeCount + ",将挖取不到任何物品!", TMsgColor.c_Red, TMsgType.t_Hint);
                                    }
                                    break;
                            }
                            // Case
                            nCode = 80;
                            if (Butch)
                            {
                                switch (HUtil32.Random(3))
                                {
                                    case 0:
                                        // 挖所需的条件达到
                                        // 随机处理挖
                                        // 挖取列表中的物品
                                        nCode = 92;
                                        if ((BaseObject != null))
                                        {
                                            if (BaseObject.m_boGhost)
                                            {
                                                return result;
                                            }
                                            if (BaseObject.m_boButchSkeleton) // 正在被挖尸体
                                            {
                                                return result;
                                            }
                                            BaseObject.m_boButchSkeleton = true;
                                            try
                                            {
                                                for (int i = ((TYanLeiWangSpider)(BaseObject)).m_ButchItemList.Count - 1; i >= 0; i--)
                                                {
                                                    if (BaseObject.m_boGhost)
                                                    {
                                                        return result;
                                                    }
                                                    if (HUtil32.GetTickCount() - BaseObject.m_dwDeathTick > (M2Share.g_Config.dwMakeGhostPlayMosterTime - 2000))
                                                    {
                                                        return result;
                                                    }
                                                    // 如果快要清理尸体时，则不再进入 20081222
                                                    if (((TYanLeiWangSpider)(BaseObject)).m_ButchItemList.Count <= 0)
                                                    {
                                                        break;
                                                    }
                                                    // 20080916
                                                    MonItem = ((TMonItemInfo)(((TYanLeiWangSpider)(BaseObject)).m_ButchItemList[i]));
                                                    if ((MonItem.ItemName).ToLower().CompareTo((M2Share.sSTRING_GOLDNAME).ToLower()) == 0)
                                                    {
                                                        // 如果是金币
                                                        nCode = 94;
                                                        this.m_nGold = this.m_nGold + MonItem.Count;
                                                        if (MonItem.Count > 0)
                                                        {
                                                            if (M2Share.g_boGameLogGold)
                                                            {
                                                                M2Share.AddGameDataLog("37" + "\09" + this.m_sMapName + "\09" + (this.m_nCurrX).ToString() + "\09" + (this.m_nCurrY).ToString() + "\09" + this.m_sCharName + "\09" + M2Share.sSTRING_GOLDNAME + "\09" + (MonItem.Count).ToString() + "\09" + "1" + "\09" + BaseObject.m_sCharName);
                                                            }
                                                        }
                                                        this.GoldChanged();
                                                        if (BaseObject != null)
                                                        {
                                                            ((TYanLeiWangSpider)(BaseObject)).m_ButchItemList.RemoveAt(i);
                                                        }
                                                        switch (ButchChargeClass)
                                                        {
                                                            case 0:
                                                                // 挖到后,删除对应的物品
                                                                // 挖取到物品后减所需的条件的数量 20080503
                                                                // 金币模式
                                                                this.m_nGold -= ButchChargeCount;
                                                                this.GoldChanged();
                                                                break;
                                                            case 1:
                                                                // 20080414 更新玩家的金币
                                                                // 元宝模式
                                                                m_nGameGold -= ButchChargeCount;
                                                                this.GameGoldChanged();
                                                                break;
                                                            case 2:
                                                                // 更新元宝数量  20080414
                                                                // 金刚石模式
                                                                m_nGAMEDIAMOND -= ButchChargeCount;
                                                                this.GameGoldChanged();
                                                                break;
                                                            case 3:
                                                                // 更新金刚石数量 20080414
                                                                // 灵符模式
                                                                m_nGAMEGIRD -= ButchChargeCount;
                                                                this.GameGoldChanged();
                                                                // 更新灵符数量 20080414
                                                                m_UseGameGird = ButchChargeCount;
                                                                // 20090108 灵符使用计数
                                                                if (M2Share.g_FunctionNPC != null)
                                                                {
                                                                    // 灵符使用触发 20090108
                                                                    M2Share.g_FunctionNPC.GotoLable(this, "@USEGAMEGIRD", false);
                                                                }
                                                                break;
                                                        }
                                                        // Case
                                                        this.SendRefMsg(Grobal2.RM_MYSHOW, Grobal2.ET_OBJECTBUTCHMON, 0, 0, 0, "");
                                                        // 挖尸体得到物品显示
                                                        break;
                                                    }
                                                    else
                                                    {
                                                        UserItem = new TUserItem();
                                                        if (M2Share.UserEngine.CopyToUserItemFromName(MonItem.ItemName, UserItem))
                                                        {
                                                            nCode = 95;
                                                            //UserItem.Dura = HUtil32.Round((UserItem.DuraMax / 100) * (20 + HUtil32.Random(80)));
                                                            if (HUtil32.Random(M2Share.g_Config.nPlayMonRandomAddValue) == 0)
                                                            {
                                                                M2Share.UserEngine.RandomUpgradeItem(UserItem);
                                                            }
                                                            nCode = 96;
                                                            if ((UserItem != null))
                                                            {
                                                                nCode = 97;
                                                                switch (ButchChargeClass)
                                                                {
                                                                    case 0:
                                                                        // 挖取到物品后减所需的条件的数量 20080503
                                                                        // 金币模式
                                                                        this.m_nGold -= ButchChargeCount;
                                                                        this.GoldChanged();
                                                                        break;
                                                                    case 1:
                                                                        // 20080414 更新玩家的金币
                                                                        // 元宝模式
                                                                        m_nGameGold -= ButchChargeCount;
                                                                        this.GameGoldChanged();
                                                                        break;
                                                                    case 2:
                                                                        // 更新元宝数量  20080414
                                                                        // 金刚石模式
                                                                        m_nGAMEDIAMOND -= ButchChargeCount;
                                                                        this.GameGoldChanged();
                                                                        break;
                                                                    case 3:
                                                                        // 更新金刚石数量 20080414
                                                                        // 灵符模式
                                                                        m_nGAMEGIRD -= ButchChargeCount;
                                                                        this.GameGoldChanged();
                                                                        // 更新灵符数量 20080414
                                                                        m_UseGameGird = ButchChargeCount;
                                                                        // 20090108 灵符使用计数
                                                                        if (M2Share.g_FunctionNPC != null)
                                                                        {
                                                                            // 灵符使用触发 20090108
                                                                            M2Share.g_FunctionNPC.GotoLable(this, "@USEGAMEGIRD", false);
                                                                        }
                                                                        break;
                                                                }
                                                                // Case
                                                                nCode = 98;
                                                                if (BaseObject != null)
                                                                {
                                                                    ((TYanLeiWangSpider)(BaseObject)).m_ButchItemList.RemoveAt(i);
                                                                }
                                                                // 挖到后,删除对应的物品
                                                                this.SendRefMsg(Grobal2.RM_MYSHOW, Grobal2.ET_OBJECTBUTCHMON, 0, 0, 0, "");
                                                                // 挖尸体得到物品显示 20080325
                                                                sCheckItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                                                                this.PlugOfCheckCanItem(7, sCheckItemName, false, 0, 0);
                                                                // 禁止物品规则(管理插件功能) 20080729
                                                                if (IsEnoughBag())
                                                                {
                                                                    // 人物的包裹是否满了 20080414
                                                                    StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                                                    if (this.IsAddWeightAvailable(StdItem.Weight))
                                                                    {
                                                                        // 人物的负重没有超过
                                                                        if (StdItem.NeedIdentify == 1)
                                                                        {
                                                                            M2Share.AddGameDataLog("37" + "\09" + this.m_sMapName + "\09" + (this.m_nCurrX).ToString() + "\09" + (this.m_nCurrY).ToString() + "\09" + this.m_sCharName + "\09" + StdItem.Name + "\09" + (UserItem.MakeIndex).ToString() + "\09" + "(" + (HUtil32.LoWord(StdItem.DC)).ToString() + "/" + (HUtil32.HiWord(StdItem.DC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MC)).ToString() + "/" + (HUtil32.HiWord(StdItem.MC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.SC)).ToString() + "/" + (HUtil32.HiWord(StdItem.SC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.AC)).ToString() + "/" + (HUtil32.HiWord(StdItem.AC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MAC)).ToString() + "/" + (HUtil32.HiWord(StdItem.MAC)).ToString() + ")" + (UserItem.btValue[0]).ToString() + "/" + (UserItem.btValue[1]).ToString() + "/" + (UserItem.btValue[2]).ToString() + "/" + (UserItem.btValue[3]).ToString() + "/" + (UserItem.btValue[4]).ToString() + "/" + (UserItem.btValue[5]).ToString() + "/" + (UserItem.btValue[6]).ToString() + "/" + (UserItem.btValue[7]).ToString() + "/" + (UserItem.btValue[8]).ToString() + "/" + (UserItem.btValue[14]).ToString() + "\09" + BaseObject.m_sCharName);
                                                                        }
                                                                        this.m_ItemList.Add(UserItem);
                                                                        nCode = 99;
                                                                        if (this.m_btRaceServer == Grobal2.RC_PLAYOBJECT)
                                                                        {
                                                                            nCode = 100;
                                                                            SendAddItem(UserItem);
                                                                            SendUpdateItem(UserItem);
                                                                            // 更新物品
                                                                        }
                                                                        break;
                                                                        // 一次只给玩家一件物品 20080121
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    nCode = 101;
                                                                    this.DropItemDown(UserItem, 3, false, false, this, this);
                                                                    // 20080610
                                                                    // '您的包裹已没有办法装下任何物品!'
                                                                    this.SysMsg(GameMsgDef.sButchEnoughBagHintMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                                                                    break;
                                                                    // 一次只给玩家一件物品 20080121
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                            //Dispose(UserItem);
                                                            UserItem = null;
                                                        }
                                                        // if CopyToUserItemFromName(MonItem.ItemName, UserItem) then begin
                                                    }
                                                    // if TYanLeiWangSpider(BaseObject).m_ButchItemList.count = 0 then SysMsg(sYouFoundNothing {未发现任何物品！！！}, c_Red, t_Hint);
                                                }
                                                // for i := TYanLeiWangSpider(BaseObject).m_ItemList.count-1 downto 0 do begin
                                            }
                                            finally
                                            {
                                                BaseObject.m_boButchSkeleton = false;
                                            }
                                        }
                                        break;
                                    case 1:
                                    case 2:
                                        // 0
                                        // 进入触发段
                                        if (!IsEnoughBag())
                                        {
                                            // '您的包裹已没有办法装下任何物品!'
                                            this.SysMsg(GameMsgDef.sButchEnoughBagHintMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                                        }
                                        if ((M2Share.g_FunctionNPC != null) && ((TYanLeiWangSpider)(BaseObject)).boIntoTrigger && IsEnoughBag())
                                        {
                                            // 20080716
                                            if (M2Share.g_FunctionNPC.m_boGotoCount < 80)
                                            {
                                                // 防止Goto数量过多,引起M2挂死 20081004
                                                nItemCount = (byte)this.m_ItemList.Count;
                                                // 进入触发段前的包裹物品数量 20080925
                                                nLevel = this.m_Abil.Level;
                                                // 进入触发段前的等级 20081018
                                                nExp = this.m_Abil.Exp;
                                                // 进入触发段前的经验 20081018
                                                nGameDiamond = m_nGAMEDIAMOND;
                                                // 进入触发段前的金刚石 20081018
                                                nCreditPoint = m_btCreditPoint;
                                                // 进入触发段前的声望 20081018
                                                nGameGird = m_nGAMEGIRD;
                                                // 进入触发段前的灵符 20081018
                                                M2Share.g_FunctionNPC.GotoLable(this, "@ButchCloneItem" + BaseObject.m_sCharName, false);
                                                if ((nItemCount < this.m_ItemList.Count) || ((nExp < this.m_Abil.Exp) && (nLevel == this.m_Abil.Level)) || ((nExp > this.m_Abil.Exp) && (nLevel < this.m_Abil.Level)) || (nGameDiamond < m_nGAMEDIAMOND) || (nCreditPoint < m_btCreditPoint) || (nGameGird < m_nGAMEGIRD))
                                                {
                                                    switch (ButchChargeClass)
                                                    {
                                                        case 0:
                                                            // 挖取到物品后减所需的条件的数量 20080503
                                                            // 金币模式
                                                            this.m_nGold -= ButchChargeCount;
                                                            this.GoldChanged();
                                                            break;
                                                        case 1:
                                                            // 20080414 更新玩家的金币
                                                            // 元宝模式
                                                            m_nGameGold -= ButchChargeCount;
                                                            this.GameGoldChanged();
                                                            break;
                                                        case 2:
                                                            // 更新元宝数量  20080414
                                                            // 金刚石模式
                                                            m_nGAMEDIAMOND -= ButchChargeCount;
                                                            this.GameGoldChanged();
                                                            break;
                                                        case 3:
                                                            // 更新金刚石数量 20080414
                                                            // 灵符模式
                                                            m_nGAMEGIRD -= ButchChargeCount;
                                                            this.GameGoldChanged();
                                                            // 更新灵符数量 20080414
                                                            m_UseGameGird = ButchChargeCount;
                                                            // 20090108 灵符使用计数
                                                            if (M2Share.g_FunctionNPC != null)
                                                            {
                                                                // 灵符使用触发 20090108
                                                                M2Share.g_FunctionNPC.GotoLable(this, "@USEGAMEGIRD", false);
                                                            }
                                                            break;
                                                    }
                                                    this.SendRefMsg(Grobal2.RM_MYSHOW, Grobal2.ET_OBJECTBUTCHMON, 0, 0, 0, "");
                                                    // 挖尸体得到物品显示 20080607
                                                }
                                            }
                                        }
                                        break;
                                }
                            }
                        }
                        break;
                    case Grobal2.RC_PLAYMOSTER:
                        // 人形怪
                        if ((HUtil32.GetTickCount() - ((TPlayMonster)(BaseObject)).m_nButchItemTime > 1000))
                        {
                            // 人形怪 20080120
                            nCode = 1;
                            Butch = false;
                            ((TPlayMonster)(BaseObject)).m_nButchItemTime = HUtil32.GetTickCount();
                            ButchChargeClass = ((TPlayMonster)(BaseObject)).m_nButchChargeClass;
                            nCode = 2;
                            // 如果目标是人形怪,已死亡且尸体存在,并且没有主人 20080605
                            // and (BaseObject.m_btSlaveExpLevel = 0)
                            if (BaseObject.m_boDeath && (!BaseObject.m_boGhost) && (!BaseObject.m_boSkeleton) && (BaseObject.m_Master == null) && (BaseObject.m_btSlaveMakeLevel == 0))
                            {
                                // 20080614
                                nCode = 3;
                                ButchChargeCount = ((TPlayMonster)(BaseObject)).m_nButchChargeCount;
                                switch (ButchChargeClass)
                                {
                                    case 0:
                                        // 挖取身上装备收费模式,并减少人物相应的数值
                                        // 金币模式
                                        if (this.m_nGold >= ButchChargeCount)
                                        {
                                            Butch = true;
                                        }
                                        else
                                        {
                                            this.SysMsg("您的金币没有达到" + (ButchChargeCount).ToString() + ",将挖取不到任何物品!", TMsgColor.c_Red, TMsgType.t_Hint);
                                        }
                                        break;
                                    case 1:
                                        // 元宝模式
                                        if (m_nGameGold >= ButchChargeCount)
                                        {
                                            Butch = true;
                                        }
                                        else
                                        {
                                            this.SysMsg("您的" + M2Share.g_Config.sGameGoldName + "没有达到" + (ButchChargeCount).ToString() + ",将挖取不到任何物品!", TMsgColor.c_Red, TMsgType.t_Hint);
                                        }
                                        break;
                                    case 2:
                                        // 金刚石模式
                                        if (m_nGAMEDIAMOND >= ButchChargeCount)
                                        {
                                            Butch = true;
                                        }
                                        else
                                        {
                                            this.SysMsg("您的" + M2Share.g_Config.sGameDiaMond + "没有达到" + (ButchChargeCount).ToString() + ",将挖取不到任何物品!", TMsgColor.c_Red, TMsgType.t_Hint);
                                        }
                                        break;
                                    case 3:
                                        // 灵符模式
                                        if (m_nGAMEGIRD >= ButchChargeCount)
                                        {
                                            Butch = true;
                                        }
                                        else
                                        {
                                            this.SysMsg("您的" + M2Share.g_Config.sGameGird + "没有达到" + (ButchChargeCount).ToString() + ",将挖取不到任何物品!", TMsgColor.c_Red, TMsgType.t_Hint);
                                        }
                                        break;
                                }
                                // Case
                                nCode = 4;
                                if (Butch)
                                {
                                    switch (HUtil32.Random(4))
                                    {
                                        case 0:
                                            nCode = 5;
                                            if (BaseObject != null)
                                            {
                                                nCode = 51;
                                                if (BaseObject.m_boGhost || (((TPlayMonster)(BaseObject)).m_ButchItemList == null))
                                                {
                                                    return result;
                                                }
                                                nCode = 52;
                                                if (BaseObject.m_boButchSkeleton) // 正在被挖尸体
                                                {
                                                    return result;
                                                }
                                                BaseObject.m_boButchSkeleton = true;
                                                try
                                                {
                                                    for (int i = ((TPlayMonster)(BaseObject)).m_ButchItemList.Count - 1; i >= 0; i--)
                                                    {
                                                        nCode = 53;
                                                        if (BaseObject.m_boGhost)
                                                        {
                                                            return result;
                                                        }
                                                        if (HUtil32.GetTickCount() - BaseObject.m_dwDeathTick > (M2Share.g_Config.dwMakeGhostPlayMosterTime - 2000)) // 如果快要清理尸体时，则不再进入
                                                        {
                                                            return result;
                                                        }
                                                        nCode = 54;
                                                        if (((TPlayMonster)(BaseObject)).m_ButchItemList.Count <= 0)
                                                        {
                                                            break;
                                                        }
                                                        nCode = 55;
                                                        MonItem = ((TMonItemInfo)(((TPlayMonster)(BaseObject)).m_ButchItemList[i]));
                                                        nCode = 103;
                                                        if ((MonItem.ItemName).ToLower().CompareTo((M2Share.sSTRING_GOLDNAME).ToLower()) == 0)// 如果是金币
                                                        {
                                                            this.m_nGold = this.m_nGold + MonItem.Count;
                                                            if (MonItem.Count > 0)
                                                            {
                                                                if (M2Share.g_boGameLogGold)
                                                                {
                                                                    M2Share.AddGameDataLog("37" + "\09" + this.m_sMapName + "\09" + this.m_nCurrX + "\09" + this.m_nCurrY +
                                                                        "\09" + this.m_sCharName + "\09" + M2Share.sSTRING_GOLDNAME + "\09" + MonItem.Count + "\09" + "1"
                                                                        + "\09" + BaseObject.m_sCharName);
                                                                }
                                                            }
                                                            this.GoldChanged();
                                                            ((TPlayMonster)(BaseObject)).m_ButchItemList.RemoveAt(i);
                                                            switch (ButchChargeClass)
                                                            {
                                                                case 0:// 挖取到物品后减所需的条件的数量 
                                                                    this.m_nGold -= ButchChargeCount;
                                                                    this.GoldChanged();
                                                                    break;
                                                                case 1:// 更新玩家的金币
                                                                    m_nGameGold -= ButchChargeCount;
                                                                    this.GameGoldChanged();
                                                                    break;
                                                                case 2:// 更新元宝数量
                                                                    m_nGAMEDIAMOND -= ButchChargeCount;
                                                                    this.GameGoldChanged();
                                                                    break;
                                                                case 3:// 更新金刚石数量
                                                                    m_nGAMEGIRD -= ButchChargeCount;
                                                                    this.GameGoldChanged();// 更新灵符数量
                                                                    m_UseGameGird = ButchChargeCount;// 灵符使用计数
                                                                    if (M2Share.g_FunctionNPC != null)  // 灵符使用触发
                                                                    {
                                                                        M2Share.g_FunctionNPC.GotoLable(this, "@USEGAMEGIRD", false);
                                                                    }
                                                                    break;
                                                            }
                                                            this.SendRefMsg(Grobal2.RM_MYSHOW, Grobal2.ET_OBJECTBUTCHMON, 0, 0, 0, "");// 挖尸体得到物品显示
                                                            break;
                                                        }
                                                        else
                                                        {
                                                            UserItem = new TUserItem();
                                                            if (M2Share.UserEngine.CopyToUserItemFromName(MonItem.ItemName, UserItem))
                                                            {
                                                                nCode = 7;
                                                                UserItem.Dura = (ushort)HUtil32.Round((double)(UserItem.DuraMax / 100) * (20 + HUtil32.Random(80)));
                                                                if (HUtil32.Random(M2Share.g_Config.nPlayMonRandomAddValue) == 0)
                                                                {
                                                                    M2Share.UserEngine.RandomUpgradeItem(UserItem);
                                                                }
                                                                nCode = 8;
                                                                if ((UserItem != null))
                                                                {
                                                                    nCode = 9;
                                                                    switch (ButchChargeClass)
                                                                    {
                                                                        case 0:// 金币模式
                                                                            this.m_nGold -= ButchChargeCount;
                                                                            this.GoldChanged();
                                                                            break;
                                                                        case 1:// 元宝模式
                                                                            m_nGameGold -= ButchChargeCount;
                                                                            this.GameGoldChanged();
                                                                            break;
                                                                        case 2:// 金刚石模式
                                                                            m_nGAMEDIAMOND -= ButchChargeCount;
                                                                            this.GameGoldChanged();
                                                                            break;
                                                                        case 3:// 灵符模式
                                                                            m_nGAMEGIRD -= ButchChargeCount;
                                                                            this.GameGoldChanged();// 更新灵符数量
                                                                            m_UseGameGird = ButchChargeCount;// 灵符使用计数
                                                                            if (M2Share.g_FunctionNPC != null)  // 灵符使用触发
                                                                            {
                                                                                M2Share.g_FunctionNPC.GotoLable(this, "@USEGAMEGIRD", false);
                                                                            }
                                                                            break;
                                                                    }
                                                                    nCode = 10;
                                                                    if (BaseObject != null)
                                                                    {
                                                                        ((TPlayMonster)(BaseObject)).m_ButchItemList.RemoveAt(i);// 挖到后,删除对应的物品
                                                                    }
                                                                    this.SendRefMsg(Grobal2.RM_MYSHOW, Grobal2.ET_OBJECTBUTCHMON, 0, 0, 0, "");// 人物挖尸体得到物品显示
                                                                    sCheckItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                                                                    this.PlugOfCheckCanItem(7, sCheckItemName, false, 0, 0);// 禁止物品规则(管理插件功能)
                                                                    if (IsEnoughBag()) // 人物的包裹是否满了
                                                                    {
                                                                        StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                                                        if (this.IsAddWeightAvailable(StdItem.Weight)) // 人物的负重没有超过
                                                                        {
                                                                            if (StdItem.NeedIdentify == 1)
                                                                            {
                                                                                M2Share.AddGameDataLog("37" + "\09" + this.m_sMapName + "\09" + (this.m_nCurrX).ToString()
                                                                                    + "\09" + (this.m_nCurrY).ToString() + "\09" + this.m_sCharName + "\09" + StdItem.Name
                                                                                    + "\09" + (UserItem.MakeIndex).ToString() + "\09" + "(" + (HUtil32.LoWord(StdItem.DC)).ToString()
                                                                                    + "/" + (HUtil32.HiWord(StdItem.DC)).ToString() + ")" + "(" +
                                                                                    (HUtil32.LoWord(StdItem.MC)).ToString() + "/" + (HUtil32.HiWord(StdItem.MC)).ToString() + ")"
                                                                                    + "(" + (HUtil32.LoWord(StdItem.SC)).ToString() + "/" + (HUtil32.HiWord(StdItem.SC)).ToString()
                                                                                    + ")" + "(" + (HUtil32.LoWord(StdItem.AC)).ToString() + "/" +
                                                                                    (HUtil32.HiWord(StdItem.AC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MAC)).ToString() +
                                                                                    "/" + (HUtil32.HiWord(StdItem.MAC)).ToString() + ")" + (UserItem.btValue[0]).ToString() + "/"
                                                                                    + (UserItem.btValue[1]).ToString() + "/" + (UserItem.btValue[2]).ToString() + "/" +
                                                                                    (UserItem.btValue[3]).ToString() + "/" + (UserItem.btValue[4]).ToString() + "/" +
                                                                                    (UserItem.btValue[5]).ToString() + "/" + (UserItem.btValue[6]).ToString() + "/" +
                                                                                    (UserItem.btValue[7]).ToString() + "/" + (UserItem.btValue[8]).ToString() + "/" +
                                                                                    (UserItem.btValue[14]).ToString() + "\09" + BaseObject.m_sCharName);
                                                                            }
                                                                            this.m_ItemList.Add(UserItem);
                                                                            nCode = 11;
                                                                            if (this.m_btRaceServer == Grobal2.RC_PLAYOBJECT)
                                                                            {
                                                                                nCode = 12;
                                                                                SendAddItem(UserItem); // 一次只给玩家一件物品 20080121
                                                                                SendUpdateItem(UserItem);// 更新物品
                                                                            }
                                                                            break;
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        nCode = 13;
                                                                        this.DropItemDown(UserItem, 3, false, false, this, this);  // 一次只给玩家一件物品 20080121
                                                                        this.SysMsg(GameMsgDef.sButchEnoughBagHintMsg, TMsgColor.c_Red, TMsgType.t_Hint); // '您的包裹已没有办法装下任何物品!'
                                                                        break;
                                                                    }
                                                                }
                                                            }
                                                            else
                                                            {
                                                                UserItem = null;
                                                            }
                                                        }
                                                    }
                                                }
                                                finally
                                                {
                                                    BaseObject.m_boButchSkeleton = false;
                                                }
                                            }
                                            break;
                                        case 1:// 0 挖身上装备
                                            nCode = 15;
                                            if ((BaseObject != null))
                                            {
                                                if (((TPlayMonster)(BaseObject)).m_boButchUseItem)// 可以挖身上装备
                                                {
                                                    if (BaseObject.m_boGhost)
                                                    {
                                                        return result;
                                                    }
                                                    if (BaseObject.m_boButchSkeleton)
                                                    {
                                                        return result;
                                                    }
                                                    BaseObject.m_boButchSkeleton = true;  // 正在被挖尸体
                                                    try
                                                    {
                                                        for (int i = m_UseItems.GetLowerBound(0); i <= m_UseItems.GetUpperBound(0); i++)
                                                        {
                                                            if (BaseObject.m_boGhost)
                                                            {
                                                                return result;
                                                            }
                                                            if (HUtil32.GetTickCount() - BaseObject.m_dwDeathTick > (M2Share.g_Config.dwMakeGhostPlayMosterTime - 2000))
                                                            {
                                                                return result;  // 如果快要清理尸体时，则不再进入
                                                            }
                                                            if (HUtil32.Random(((TPlayMonster)(BaseObject)).m_nButchRate) != 0)
                                                            {
                                                                continue;    // 挖取身上装备机率0为百分百，数字越大，机率越小
                                                            }
                                                            K = HUtil32.Random(14);// 修正不能挖到斗笠位物品
                                                            if (M2Share.InDisableTakeOffList(((TPlayMonster)(BaseObject)).m_UseItems[K].wIndex) || (((TPlayMonster)(BaseObject)).m_UseItems[K].wIndex == 0))
                                                            {
                                                                continue;// 检查是否在禁止取下列表,如果在列表中则不掉此物品
                                                            }
                                                            StdItem = M2Share.UserEngine.GetStdItem(((TPlayMonster)(BaseObject)).m_UseItems[K].wIndex);
                                                            nCode = 17;
                                                            if ((StdItem != null))
                                                            {
                                                                switch (ButchChargeClass)
                                                                {
                                                                    case 0:// 挖取到物品后减所需的条件的数量 金币模式
                                                                        this.m_nGold -= ButchChargeCount;
                                                                        this.GoldChanged();
                                                                        break;
                                                                    case 1:// 更新玩家的金币 元宝模式
                                                                        m_nGameGold -= ButchChargeCount;
                                                                        this.GameGoldChanged();
                                                                        break;
                                                                    case 2:// 更新元宝数量 金刚石模式
                                                                        m_nGAMEDIAMOND -= ButchChargeCount;
                                                                        this.GameGoldChanged();
                                                                        break;
                                                                    case 3:// 更新金刚石数量 灵符模式
                                                                        m_nGAMEGIRD -= ButchChargeCount;
                                                                        this.GameGoldChanged();// 更新灵符数量
                                                                        m_UseGameGird = ButchChargeCount;// 灵符使用计数
                                                                        if (M2Share.g_FunctionNPC != null)
                                                                        {
                                                                            M2Share.g_FunctionNPC.GotoLable(this, "@USEGAMEGIRD", false); // 灵符使用触发
                                                                        }
                                                                        break;
                                                                }
                                                                if (((TPlayMonster)BaseObject).m_UseItems[K].wIndex != 0)
                                                                {
                                                                    UserItem = ((TPlayMonster)(BaseObject)).m_UseItems[K];
                                                                    this.SendRefMsg(Grobal2.RM_MYSHOW, Grobal2.ET_OBJECTBUTCHMON, 0, 0, 0, "");// 人物挖尸体得到物品显示
                                                                    ((TPlayMonster)BaseObject).m_UseItems[K].wIndex = 0;
                                                                    sCheckItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                                                                    nCode = 22;
                                                                    this.PlugOfCheckCanItem(7, sCheckItemName, false, 0, 0);// 禁止物品规则(管理插件功能)
                                                                    if (IsEnoughBag() && this.IsAddWeightAvailable(StdItem.Weight))// 物品是数据库里的物品,并人物的负重没有超过
                                                                    {
                                                                        if (StdItem.NeedIdentify == 1)
                                                                        {
                                                                            M2Share.AddGameDataLog("37" + "\09" + this.m_sMapName + "\09" + this.m_nCurrX + "\09" +
                                                                            this.m_nCurrY + "\09" + this.m_sCharName + "\09" + StdItem.Name
                                                                            + "\09" + (UserItem.MakeIndex).ToString() + "\09" + "(" + HUtil32.LoWord(StdItem.DC) + "/"
                                                                            + (HUtil32.HiWord(StdItem.DC)).ToString() + ")" + "(" + HUtil32.LoWord(StdItem.MC) + "/" + HUtil32.HiWord(StdItem.MC) + ")"
                                                                            + "(" + HUtil32.LoWord(StdItem.SC) + "/" + HUtil32.HiWord(StdItem.SC) + ")" + "(" + HUtil32.LoWord(StdItem.AC) + "/"
                                                                            + HUtil32.HiWord(StdItem.AC) + ")" + "(" + HUtil32.LoWord(StdItem.MAC) + "/" + HUtil32.HiWord(StdItem.MAC) + ")" +
                                                                            UserItem.btValue[0] + "/" + UserItem.btValue[1] + "/" + UserItem.btValue[2] + "/" + UserItem.btValue[3] + "/"
                                                                            + UserItem.btValue[4] + "/" + (UserItem.btValue[5]).ToString() + "/" + (UserItem.btValue[6]).ToString()
                                                                            + "/" + UserItem.btValue[7] + "/" + UserItem.btValue[8] + "/" + UserItem.btValue[14] + "\09" + BaseObject.m_sCharName);
                                                                        }
                                                                        this.m_ItemList.Add(UserItem);
                                                                        if (this.m_btRaceServer == Grobal2.RC_PLAYOBJECT)
                                                                        {
                                                                            SendAddItem(UserItem);
                                                                            SendUpdateItem(UserItem);// 更新物品
                                                                        }
                                                                        break;
                                                                    }
                                                                    else
                                                                    {
                                                                        nCode = 14;
                                                                        if (UserItem != null)
                                                                        {
                                                                            this.DropItemDown(UserItem, 3, false, false, this, this);
                                                                        }
                                                                        this.SysMsg(GameMsgDef.sButchEnoughBagHintMsg, TMsgColor.c_Red, TMsgType.t_Hint); // '您的包裹已没有办法装下任何物品!'
                                                                        break;
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                   UserItem=null;
                                                                }
                                                            }
                                                        }
                                                    }
                                                    finally
                                                    {
                                                        BaseObject.m_boButchSkeleton = false;
                                                    }
                                                }
                                                else
                                                {
                                                    nCode = 23;
                                                    if ((BaseObject != null))
                                                    {
                                                        if (BaseObject.m_boGhost)
                                                        {
                                                            return result;
                                                        }
                                                        nCode = 232;
                                                        if (BaseObject.m_boButchSkeleton)
                                                        {
                                                            return result;
                                                        }
                                                        BaseObject.m_boButchSkeleton = true; // 正在被挖尸体
                                                        try
                                                        {
                                                            for (int i = ((TPlayMonster)(BaseObject)).m_ButchItemList.Count - 1; i >= 0; i--)
                                                            {
                                                                nCode = 233;
                                                                if (BaseObject.m_boGhost)
                                                                {
                                                                    return result;
                                                                }
                                                                nCode = 234;
                                                                if (HUtil32.GetTickCount() - BaseObject.m_dwDeathTick > (M2Share.g_Config.dwMakeGhostPlayMosterTime - 2000))
                                                                {
                                                                    return result;// 如果快要清理尸体时，则不再进入
                                                                }
                                                                nCode = 24;
                                                                if (((TPlayMonster)BaseObject).m_ButchItemList.Count <= 0)
                                                                {
                                                                    break;
                                                                }
                                                                MonItem = ((TMonItemInfo)(((TPlayMonster)(BaseObject)).m_ButchItemList[i]));
                                                                if (MonItem != null)
                                                                {
                                                                    if ((MonItem.ItemName).ToLower().CompareTo((M2Share.sSTRING_GOLDNAME).ToLower()) == 0) // 如果是金币
                                                                    {
                                                                        nCode = 25;
                                                                        this.m_nGold = this.m_nGold + MonItem.Count;
                                                                        this.GoldChanged();
                                                                        if (MonItem.Count > 0)
                                                                        {
                                                                            if (M2Share.g_boGameLogGold)
                                                                            {
                                                                                M2Share.AddGameDataLog("37" + "\09" + this.m_sMapName + "\09" + (this.m_nCurrX).ToString()
                                                                                    + "\09" + (this.m_nCurrY).ToString() + "\09" + this.m_sCharName + "\09" + M2Share.sSTRING_GOLDNAME
                                                                                    + "\09" + (MonItem.Count).ToString() + "\09" + "1" + "\09" + BaseObject.m_sCharName);
                                                                            }
                                                                        }
                                                                        if (BaseObject != null)
                                                                        {
                                                                            ((TPlayMonster)(BaseObject)).m_ButchItemList.RemoveAt(i);// 挖到后,删除对应的物品
                                                                        }
                                                                        switch (ButchChargeClass)
                                                                        {
                                                                            case 0:// 挖取到物品后减所需的条件的数量 金币模式
                                                                                this.m_nGold -= ButchChargeCount;
                                                                                this.GoldChanged();
                                                                                break;
                                                                            case 1:// 更新玩家的金币 元宝模式
                                                                                m_nGameGold -= ButchChargeCount;
                                                                                this.GameGoldChanged();
                                                                                break;
                                                                            case 2:// 更新元宝数量 金刚石模式
                                                                                m_nGAMEDIAMOND -= ButchChargeCount;
                                                                                this.GameGoldChanged();
                                                                                break;
                                                                            case 3:// 更新金刚石数量  灵符模式
                                                                                m_nGAMEGIRD -= ButchChargeCount;
                                                                                this.GameGoldChanged();// 更新灵符数量
                                                                                m_UseGameGird = ButchChargeCount;//灵符使用计数
                                                                                if (M2Share.g_FunctionNPC != null)
                                                                                {
                                                                                    M2Share.g_FunctionNPC.GotoLable(this, "@USEGAMEGIRD", false);// 灵符使用触发
                                                                                }
                                                                                break;
                                                                        }
                                                                        this.SendRefMsg(Grobal2.RM_MYSHOW, Grobal2.ET_OBJECTBUTCHMON, 0, 0, 0, "");// 挖尸体得到物品显示
                                                                        break;
                                                                    }
                                                                    else
                                                                    {
                                                                        nCode = 26;
                                                                        UserItem = new TUserItem();
                                                                        if (M2Share.UserEngine.CopyToUserItemFromName(MonItem.ItemName, UserItem))
                                                                        {
                                                                            UserItem.Dura = (ushort)HUtil32.Round((double)(UserItem.DuraMax / 100) * (20 + HUtil32.Random(80)));
                                                                            nCode = 27;
                                                                            if (HUtil32.Random(M2Share.g_Config.nPlayMonRandomAddValue) == 0)
                                                                            {
                                                                                M2Share.UserEngine.RandomUpgradeItem(UserItem);
                                                                            }
                                                                            if ((UserItem != null))
                                                                            {
                                                                                switch (ButchChargeClass)
                                                                                {
                                                                                    case 0:// 挖取到物品后减所需的条件的数量 金币模式
                                                                                        this.m_nGold -= ButchChargeCount;
                                                                                        this.GoldChanged();
                                                                                        break;
                                                                                    case 1:// 更新玩家的金币 元宝模式
                                                                                        m_nGameGold -= ButchChargeCount;
                                                                                        this.GameGoldChanged();
                                                                                        break;
                                                                                    case 2:// 更新元宝数量 金刚石模式
                                                                                        m_nGAMEDIAMOND -= ButchChargeCount;
                                                                                        this.GameGoldChanged();
                                                                                        break;
                                                                                    case 3:// 更新金刚石数量  灵符模式
                                                                                        m_nGAMEGIRD -= ButchChargeCount;
                                                                                        this.GameGoldChanged();// 更新灵符数量
                                                                                        m_UseGameGird = ButchChargeCount;// 灵符使用计数
                                                                                        if (M2Share.g_FunctionNPC != null)
                                                                                        {
                                                                                            M2Share.g_FunctionNPC.GotoLable(this, "@USEGAMEGIRD", false);// 灵符使用触发
                                                                                        }
                                                                                        break;
                                                                                }
                                                                                nCode = 28;
                                                                                if (BaseObject != null)
                                                                                {
                                                                                    ((TPlayMonster)(BaseObject)).m_ButchItemList.RemoveAt(i);  // 挖到后,删除对应的物品
                                                                                }
                                                                                this.SendRefMsg(Grobal2.RM_MYSHOW, Grobal2.ET_OBJECTBUTCHMON, 0, 0, 0, "");// 人物挖尸体得到物品显示
                                                                                sCheckItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                                                                                nCode = 129;
                                                                                this.PlugOfCheckCanItem(7, sCheckItemName, false, 0, 0);// 禁止物品规则(管理插件功能)
                                                                                if (IsEnoughBag())  // 人物的包裹是否满了
                                                                                {
                                                                                    StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                                                                    if (this.IsAddWeightAvailable(StdItem.Weight)) // 人物的负重没有超过
                                                                                    {
                                                                                        if (StdItem.NeedIdentify == 1)
                                                                                        {
                                                                                            M2Share.AddGameDataLog("37" + "\09" + this.m_sMapName
                                                                                                + "\09" + (this.m_nCurrX).ToString() + "\09" + (this.m_nCurrY).ToString()
                                                                                                + "\09" + this.m_sCharName + "\09" + StdItem.Name + "\09"
                                                                                                + (UserItem.MakeIndex).ToString() + "\09" + "(" + (HUtil32.LoWord(StdItem.DC)).ToString() + "/"
                                                                                                + (HUtil32.HiWord(StdItem.DC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MC)).ToString()
                                                                                                + "/" + (HUtil32.HiWord(StdItem.MC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.SC)).ToString() + "/"
                                                                                                + (HUtil32.HiWord(StdItem.SC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.AC)).ToString() + "/" + (HUtil32.HiWord(StdItem.AC)).ToString() + ")"
                                                                                                + "(" + (HUtil32.LoWord(StdItem.MAC)).ToString() + "/" + (HUtil32.HiWord(StdItem.MAC)).ToString() + ")" + (UserItem.btValue[0]).ToString() + "/"
                                                                                                + (UserItem.btValue[1]).ToString() + "/" + (UserItem.btValue[2]).ToString() + "/" + (UserItem.btValue[3]).ToString() + "/"
                                                                                                + (UserItem.btValue[4]).ToString() + "/" + (UserItem.btValue[5]).ToString() + "/" + (UserItem.btValue[6]).ToString() + "/"
                                                                                                + (UserItem.btValue[7]).ToString() + "/" + (UserItem.btValue[8]).ToString() + "/" + (UserItem.btValue[14]).ToString() + "\09" + BaseObject.m_sCharName);
                                                                                        }
                                                                                        this.m_ItemList.Add(UserItem);
                                                                                        nCode = 30;
                                                                                        if (this.m_btRaceServer == Grobal2.RC_PLAYOBJECT)
                                                                                        {
                                                                                            SendAddItem(UserItem); // 一次只给玩家一件物品
                                                                                            SendUpdateItem(UserItem); // 更新物品
                                                                                        }
                                                                                        break;
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    nCode = 31;
                                                                                    this.DropItemDown(UserItem, 3, false, false, this, this);// '您的包裹已没有办法装下任何物品!'
                                                                                    this.SysMsg(GameMsgDef.sButchEnoughBagHintMsg, TMsgColor.c_Red, TMsgType.t_Hint);// 一次只给玩家一件物品 20080121
                                                                                    break;
                                                                                }
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                           UserItem=null;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        finally
                                                        {
                                                            BaseObject.m_boButchSkeleton = false;
                                                        }
                                                    }
                                                }
                                            }
                                            break;
                                        case 2:
                                        case 3:
                                            if (!IsEnoughBag())
                                            {
                                                this.SysMsg(GameMsgDef.sButchEnoughBagHintMsg, TMsgColor.c_Red, TMsgType.t_Hint);// '您的包裹已没有办法装下任何物品!'
                                            }
                                            if ((BaseObject != null) && (M2Share.g_FunctionNPC != null) && ((TPlayMonster)(BaseObject)).boIntoTrigger && IsEnoughBag())
                                            {
                                                nCode = 35;
                                                if (M2Share.g_FunctionNPC.m_boGotoCount < 80)
                                                {
                                                    nItemCount = (byte)this.m_ItemList.Count;// 进入触发段前的包裹物品数量 
                                                    nLevel = this.m_Abil.Level;// 进入触发段前的等级 
                                                    nExp = this.m_Abil.Exp;// 进入触发段前的经验 
                                                    nGameDiamond = m_nGAMEDIAMOND;// 进入触发段前的金刚石 
                                                    nCreditPoint = m_btCreditPoint;// 进入触发段前的声望 
                                                    nGameGird = m_nGAMEGIRD;// 进入触发段前的灵符 
                                                    M2Share.g_FunctionNPC.GotoLable(this, "@ButchCloneItem" + BaseObject.m_sCharName, false);
                                                    if ((nItemCount < this.m_ItemList.Count) || ((nExp < this.m_Abil.Exp) && (nLevel == this.m_Abil.Level)) || ((nExp > this.m_Abil.Exp) && (nLevel < this.m_Abil.Level)) || (nGameDiamond < m_nGAMEDIAMOND) || (nCreditPoint < m_btCreditPoint) || (nGameGird < m_nGAMEGIRD))
                                                    {
                                                        switch (ButchChargeClass)
                                                        {
                                                            case 0:// 挖取到物品后减所需的条件的数量 金币模式
                                                                this.m_nGold -= ButchChargeCount;
                                                                this.GoldChanged();
                                                                break;
                                                            case 1://更新玩家的金币 元宝模式
                                                                m_nGameGold -= ButchChargeCount;
                                                                this.GameGoldChanged();
                                                                break;
                                                            case 2:// 更新元宝数量  金刚石模式
                                                                m_nGAMEDIAMOND -= ButchChargeCount;
                                                                this.GameGoldChanged();
                                                                break;
                                                            case 3:// 更新金刚石数量 灵符模式
                                                                m_nGAMEGIRD -= ButchChargeCount;
                                                                this.GameGoldChanged();// 更新灵符数量
                                                                m_UseGameGird = ButchChargeCount;// 灵符使用计数
                                                                if (M2Share.g_FunctionNPC != null)
                                                                {
                                                                    M2Share.g_FunctionNPC.GotoLable(this, "@USEGAMEGIRD", false);  // 灵符使用触发
                                                                }
                                                                break;
                                                        }
                                                        this.SendRefMsg(Grobal2.RM_MYSHOW, Grobal2.ET_OBJECTBUTCHMON, 0, 0, 0, "");// 人物挖尸体得到物品显示
                                                    }
                                                }
                                            }
                                            break;
                                    }
                                }
                            }
                        }
                        break;
                    default:
                        nCode = 37;
                        if ((Math.Abs(nX - this.m_nCurrX) <= 2) && (Math.Abs(nY - this.m_nCurrY) <= 2))
                        {
                            nCode = 38;
                            if (this.m_PEnvir.IsValidObject(nX, nY, 2, BaseObject))
                            {
                                nCode = 39;
                                if (BaseObject.m_boDeath && (!BaseObject.m_boSkeleton) && (BaseObject.m_boAnimal))
                                {
                                    n10 = HUtil32.Random(16) + 5;
                                    n14 = HUtil32.Random(201) + 100;
                                    BaseObject.m_nBodyLeathery -= n10;
                                    BaseObject.m_nMeatQuality -= n14;
                                    nCode = 40;
                                    if (BaseObject.m_nMeatQuality < 0)
                                    {
                                        BaseObject.m_nMeatQuality = 0;
                                    }
                                    nCode = 41;
                                    if (BaseObject.m_nBodyLeathery <= 0)
                                    {
                                        if ((BaseObject.m_btRaceServer >= Grobal2.RC_ANIMAL) && (BaseObject.m_btRaceServer < Grobal2.RC_MONSTER))
                                        {
                                            BaseObject.m_boSkeleton = true;
                                            this.ApplyMeatQuality();// 设置肉的品质
                                            BaseObject.SendRefMsg(Grobal2.RM_SKELETON, BaseObject.m_btDirection, BaseObject.m_nCurrX, BaseObject.m_nCurrY, 0, "");// 彻底死了,不再有动作
                                        }
                                        if (!this.TakeBagItems(BaseObject))
                                        {
                                            this.SysMsg(GameMsgDef.sYouFoundNothing, TMsgColor.c_Red, TMsgType.t_Hint);// 未发现任何物品！！！
                                        }
                                        BaseObject.m_nBodyLeathery = 50;
                                    }

                                    this.m_dwDeathTick = HUtil32.GetTickCount();
                                }
                            }
                            this.m_btDirection = btDir;
                        }
                        nCode = 42;
                        break;
                }
                this.SendRefMsg(Grobal2.RM_BUTCH, this.m_btDirection, this.m_nCurrX, this.m_nCurrY, 0, "");// 让别人看到挖的动作
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TPlayObject.ClientGetButchItem Code:" + (nCode).ToString());
            }
            return result;
        }

        /// <summary>
        /// 客户端改变魔法快键
        /// </summary>
        /// <param name="nSkillIdx"></param>
        /// <param name="nKey"></param>
        private void ClientChangeMagicKey(int nSkillIdx, int nKey)
        {
            TUserMagic UserMagic;
            if (this.m_MagicList.Count > 0)
            {
                for (int i = 0; i < this.m_MagicList.Count; i++)
                {
                    UserMagic = this.m_MagicList[i];
                    if (UserMagic.MagicInfo.wMagicId == nSkillIdx)
                    {
                        UserMagic.btKey = (byte)nKey;
                        break;
                    }
                }
            }
        }

        /// <summary>
        /// 客户端关闭组队
        /// </summary>
        private void ClientGropuClose()
        {
            if (m_GroupOwner == null)
            {
                m_boAllowGroup = false;
                return;
            }
            if (m_GroupOwner != this)
            {
                m_GroupOwner.DelMember(this);
                m_boAllowGroup = false;
            }
            else
            {
                this.SysMsg("如果您想退出，使用编组功能（删除按钮）", TMsgColor.c_Red, TMsgType.t_Hint);
            }
        }

        /// <summary>
        /// 新建组队
        /// </summary>
        /// <param name="sHumName"></param>
        private void ClientCreateGroup(string sHumName)
        {
            TPlayObject PlayObject;
            if (this.m_boDeath || this.m_boGhost)// 死亡后不能组队
            {
                return;
            }
            PlayObject = M2Share.UserEngine.GetPlayObject(sHumName);
            if (m_GroupOwner != null)
            {
                SendDefMessage(Grobal2.SM_CREATEGROUP_FAIL, -1, 0, 0, 0, "");
                return;
            }
            if ((PlayObject == null) || (PlayObject == this) || PlayObject.m_boDeath || PlayObject.m_boGhost)
            {
                SendDefMessage(Grobal2.SM_CREATEGROUP_FAIL, -2, 0, 0, 0, "");
                return;
            }
            if ((PlayObject.m_GroupOwner != null))
            {
                SendDefMessage(Grobal2.SM_CREATEGROUP_FAIL, -3, 0, 0, 0, "");
                return;
            }
            if ((!PlayObject.m_boAllowGroup))
            {
                SendDefMessage(Grobal2.SM_CREATEGROUP_FAIL, -4, 0, 0, 0, "");
                return;
            }
            m_GroupMembers.Clear();
            m_GroupMembers.Add(this);
            m_GroupMembers.Add(PlayObject);
            JoinGroup(this);
            PlayObject.JoinGroup(this);
            m_boAllowGroup = true;
            SendDefMessage(Grobal2.SM_CREATEGROUP_OK, 0, 0, 0, 0, "");
            SendGroupMembers();
        }

        /// <summary>
        /// 增加组队成员
        /// </summary>
        /// <param name="sHumName"></param>
        private void ClientAddGroupMember(string sHumName)
        {
            TPlayObject PlayObject;
            if (this.m_boDeath || this.m_boGhost) // 死亡后不能增加组队成员
            {
                return;
            }
            PlayObject = M2Share.UserEngine.GetPlayObject(sHumName);
            if (m_GroupOwner != this)
            {
                SendDefMessage(Grobal2.SM_GROUPADDMEM_FAIL, -1, 0, 0, 0, "");// 编组还未成立
                return;
            }
            if (m_GroupMembers.Count > M2Share.g_Config.nGroupMembersMax) // 超过成员上限
            {
                SendDefMessage(Grobal2.SM_GROUPADDMEM_FAIL, -5, 0, 0, 0, "");// 您想邀请加入编组的人已经加入了其它组！
                return;
            }
            if ((PlayObject == null) || (PlayObject == this) || PlayObject.m_boDeath || PlayObject.m_boGhost)
            {
                SendDefMessage(Grobal2.SM_GROUPADDMEM_FAIL, -2, 0, 0, 0, "");// 输入的人物名称不正确
                return;
            }
            if ((PlayObject.m_GroupOwner != null))
            {
                SendDefMessage(Grobal2.SM_GROUPADDMEM_FAIL, -3, 0, 0, 0, "");// 已经加入编组
                return;
            }
            if ((!PlayObject.m_boAllowGroup)) // 对方不允许编组
            {
                SendDefMessage(Grobal2.SM_GROUPADDMEM_FAIL, -4, 0, 0, 0, "");
                return;
            }
            if (IsGroupMember(PlayObject))// 检查是否是组队里成员
            {
                SendDefMessage(Grobal2.SM_GROUPADDMEM_FAIL, -3, 0, 0, 0, "");// 已经加入编组
                return;
            }
            m_GroupMembers.Add(PlayObject);
            PlayObject.JoinGroup(this);
            SendDefMessage(Grobal2.SM_GROUPADDMEM_OK, 0, 0, 0, 0, "");
            SendGroupMembers();
        }

        /// <summary>
        /// 客户端删除组队成员
        /// </summary>
        /// <param name="sHumName"></param>
        private void ClientDelGroupMember(string sHumName)
        {
            TPlayObject PlayObject;
            PlayObject = M2Share.UserEngine.GetPlayObject(sHumName);
            if (m_GroupOwner != this)
            {
                SendDefMessage(Grobal2.SM_GROUPDELMEM_FAIL, -1, 0, 0, 0, "");
                return;
            }
            if (PlayObject == null)
            {
                SendDefMessage(Grobal2.SM_GROUPDELMEM_FAIL, -2, 0, 0, 0, "");
                return;
            }
            if (!IsGroupMember(PlayObject))
            {
                SendDefMessage(Grobal2.SM_GROUPDELMEM_FAIL, -3, 0, 0, 0, "");
                return;
            }
            DelMember(PlayObject);
            SendDefMessage(Grobal2.SM_GROUPDELMEM_OK, 0, 0, 0, 0, sHumName);
        }

        // 判断对方是否面对面,是则可以交易
        private void ClientDealTry(string sHumName)
        {
            TBaseObject BaseObject;
            TPlayObject PlayObject;
            if (M2Share.g_Config.boDisableDeal)
            {
                this.SendMsg(M2Share.g_ManageNPC, Grobal2.RM_MENU_OK, 0, this.m_ActorsId, 0, 0, GameMsgDef.g_sDisableDealItemsMsg);
                return;
            }
            if (m_boDealing)
            {
                return;
            }
            if (HUtil32.GetTickCount() - m_DealLastTick < M2Share.g_Config.dwTryDealTime)// 3000
            {
                this.SendMsg(M2Share.g_ManageNPC, Grobal2.RM_MENU_OK, 0, this.m_ActorsId, 0, 0, GameMsgDef.g_sPleaseTryDealLaterMsg);
                return;
            }
            if (!m_boCanDeal)
            {
                this.SendMsg(M2Share.g_ManageNPC, Grobal2.RM_MENU_OK, 0, this.m_ActorsId, 0, 0, GameMsgDef.g_sCanotTryDealMsg);
                return;
            }
            BaseObject = this.GetPoseCreate();
            if ((BaseObject != null) && (BaseObject != this) && (BaseObject.m_btRaceServer == Grobal2.RC_PLAYOBJECT))
            {
                PlayObject = ((BaseObject) as TPlayObject);
                if ((PlayObject != null) && (PlayObject.GetPoseCreate() == this) && (!PlayObject.m_boDealing))
                {
                    if ((PlayObject.m_boAllowDeal && PlayObject.m_boCanDeal))
                    {
                        PlayObject.SysMsg(this.m_sCharName + GameMsgDef.g_sOpenedDealMsg, TMsgColor.c_Green, TMsgType.t_Hint);
                        this.SysMsg(PlayObject.m_sCharName + GameMsgDef.g_sOpenedDealMsg, TMsgColor.c_Green, TMsgType.t_Hint);
                        ((this) as TPlayObject).OpenDealDlg(PlayObject);
                        PlayObject.OpenDealDlg(this);
                    }
                    else
                    {
                        // '对方禁止进入交易'
                        this.SysMsg(GameMsgDef.g_sPoseDisableDealMsg, TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                }
                else
                {
                    SendDefMessage(Grobal2.SM_DEALTRY_FAIL, 0, 0, 0, 0, "");
                }
            }
            else
            {
                SendDefMessage(Grobal2.SM_DEALTRY_FAIL, 0, 0, 0, 0, "");
            }
        }

        /// <summary>
        /// 客户端增加寄售物品到出售框中
        /// </summary>
        private void ClientAddSellOffItem(int nItemIdx, string sItemName)
        {
            bool bo11;
            TUserItem UserItem;
            string sUserItemName;
            m_boCanQueryBag = true;// 增加寄售物品时,不能刷新包裹
            try
            {
                if (sItemName.IndexOf(" ") >= 0)
                {
                    // 折分物品名称(信件物品的名称后面加了使用次数)
                    HUtil32.GetValidStr3(sItemName, ref sItemName, new string[] { " " });
                }
                bo11 = false;
                if (!m_boSellOffOK)
                {
                    for (int i = this.m_ItemList.Count - 1; i >= 0; i--)
                    {
                        if (this.m_ItemList.Count <= 0)
                        {
                            break;
                        }
                        UserItem = this.m_ItemList[i];
                        if (UserItem == null)
                        {
                            continue;
                        }
                        if (UserItem.MakeIndex == nItemIdx)
                        {
                            sUserItemName = "";  // 取自定义物品名称
                            if (UserItem.btValue[13] == 1)
                            {
                                sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                            }
                            if (sUserItemName == "")
                            {
                                sUserItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                            }
                            if (((sUserItemName).ToLower().CompareTo((sItemName).ToLower()) == 0) && (m_SellOffItemList.Count < 9))
                            {
                                if (this.CheckItemValue(UserItem, 1))//禁止交易
                                {
                                    break;
                                }
                                else if (this.PlugOfCheckCanItem(1, sUserItemName, false, 0, 0))  // 禁止物品规则(管理插件功能)
                                {
                                    break;
                                }
                                m_SellOffItemList.Add(UserItem);
                                this.SendMsg(this, Grobal2.RM_SELLOFFADDITEM_OK, 0, 0, 0, 0, "");// 放物品成功
                                this.m_ItemList.RemoveAt(i);
                                ClearCopyItem(0, UserItem.wIndex, UserItem.MakeIndex);// 清理包裹和仓库复制物品
                                bo11 = true;
                                break;
                            }
                        }
                    }
                }
                if (!bo11)
                {
                    this.SendMsg(this, Grobal2.RM_SellOffADDITEM_FAIL, 0, 0, 0, 0, "");
                }
            }
            finally
            {
                m_boCanQueryBag = false;// 增加寄售物品时,不能刷新包裹
            }
        }

        /// <summary>
        /// 客户端删除出售物品窗里的物品
        /// </summary>
        private void ClientDelSellOffItem(int nItemIdx, string sItemName)
        {
            bool bo11;
            TUserItem UserItem = null;
            string sUserItemName;
            if (sItemName.IndexOf(" ") >= 0)
            {
                // 折分物品名称(信件物品的名称后面加了使用次数)
                HUtil32.GetValidStr3(sItemName, ref sItemName, new string[] { " " });
            }
            bo11 = false;
            if (!m_boSellOffOK)
            {
                for (int i = m_SellOffItemList.Count - 1; i >= 0; i--)
                {
                    if (m_SellOffItemList.Count <= 0)
                    {
                        break;
                    }
                    UserItem = m_SellOffItemList[i];
                    if (UserItem == null)
                    {
                        continue;
                    }
                    if (UserItem.MakeIndex == nItemIdx)
                    {
                        // 取自定义物品名称
                        sUserItemName = "";
                        if (UserItem.btValue[13] == 1)
                        {
                            sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                        }
                        if (sUserItemName == "")
                        {
                            sUserItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                        }
                        if ((sUserItemName).ToLower().CompareTo((sItemName).ToLower()) == 0)
                        {
                            ClearCopyItem(0, UserItem.wIndex, UserItem.MakeIndex);// 清理包裹和仓库复制物品
                            this.m_ItemList.Add(UserItem);
                            this.SendMsg(this, Grobal2.RM_SELLOFFDELITEM_OK, 0, 0, 0, 0, "");
                            m_SellOffItemList.RemoveAt(i);
                            bo11 = true;
                            break;
                        }
                    }
                }
            }
            if (!bo11)
            {
                this.SendMsg(this, Grobal2.RM_SELLOFFDELITEM_FAIL, 0, 0, 0, 0, "");
            }
        }

        // 客户端元宝寄售结束(出售物品)
        // 出售人取消正在出售中的交易
        private void ClientCancelSellOffIng()
        {
            TDealOffInfo DealOffInfo;
            TStdItem StdItem;
            TUserItem UserItem;
            try
            {
                if ((M2Share.sSellOffItemList == null) || (M2Share.sSellOffItemList.Count == 0) || (!IsEnoughBag()))
                {
                    return;
                }
                for (int i = M2Share.sSellOffItemList.Count - 1; i >= 0; i--)
                {
                    if (M2Share.sSellOffItemList.Count <= 0)
                    {
                        break;
                    }
                    DealOffInfo = M2Share.sSellOffItemList[i];
                    if ((DealOffInfo != null))
                    {
                        if (((DealOffInfo.sDealCharName).ToLower().CompareTo((this.m_sCharName).ToLower()) == 0)
                            && ((DealOffInfo.N == 0) || (DealOffInfo.N == 3)))
                        {
                            DealOffInfo.N = 4;//正在操作中
                            for (int K = 0; K <= 9; K++)
                            {
                                StdItem = M2Share.UserEngine.GetStdItem(DealOffInfo.UseItems[K].wIndex);
                                if ((StdItem != null))
                                {
                                    UserItem = new TUserItem();
                                    UserItem = DealOffInfo.UseItems[K];
                                    if (IsEnoughBag()) // 人物的包裹是否满了
                                    {
                                        if (this.IsAddWeightAvailable(StdItem.Weight))// 检查负重
                                        {
                                            if (this.AddItemToBag(UserItem))
                                            {
                                                SendAddItem(UserItem);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        this.DropItemDown(UserItem, 3, false, false, this, this);
                                    }
                                }
                                else if ((DealOffInfo.UseItems[K].MakeIndex > 0) && (DealOffInfo.UseItems[K].wIndex == ushort.MaxValue) &&
                                    (DealOffInfo.UseItems[K].Dura == ushort.MaxValue) && (DealOffInfo.UseItems[K].DuraMax == ushort.MaxValue)) // 是金刚石
                                {
                                    m_nGAMEDIAMOND += DealOffInfo.UseItems[K].MakeIndex;// 增加金刚石
                                    this.GameGoldChanged();// 更新金刚石数量
                                }
                            }
                            M2Share.sSellOffItemList.RemoveAt(i);
                            Dispose(DealOffInfo);
                            this.SendMsg(this, Grobal2.RM_MENU_OK, 0, this.m_ActorsId, 0, 0, "取消寄售成功！");
                            // FrmDB.SaveSellOffItemList;//保存元宝寄售列表
                        }
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TPlayObject.ClientCancelSellOffIng");
            }
        }

        // 出售人取消正在出售中的交易
        // 购买人取消交易
        private void ClientBuyCancelSellOff(string DealCharName)
        {
            TDealOffInfo DealOffInfo;
            for (int i = M2Share.sSellOffItemList.Count - 1; i >= 0; i--)
            {
                if (M2Share.sSellOffItemList.Count <= 0)
                {
                    break;
                }
                DealOffInfo = M2Share.sSellOffItemList[i];
                if ((DealOffInfo != null))
                {
                    if (((DealOffInfo.sDealCharName).ToLower().CompareTo((DealCharName).ToLower()) == 0) && ((DealOffInfo.sBuyCharName).ToLower().CompareTo((this.m_sCharName).ToLower()) == 0) && (DealOffInfo.N == 0))
                    {
                        DealOffInfo.N = 3;// 购买人取消标识
                        this.SendMsg(this, Grobal2.RM_MENU_OK, 0, this.m_ActorsId, 0, 0, "取消交易成功！");
                        break;
                    }
                }
            }
        }

        /// <summary>
        /// 购买寄售物品
        /// </summary>
        /// <param name="DealCharName"></param>
        private void ClientBuySellOffItme(string DealCharName)
        {
            TDealOffInfo DealOffInfo;
            TStdItem StdItem;
            TUserItem UserItem;
            TPlayObject PlayObject;
            try
            {
                for (int i = M2Share.sSellOffItemList.Count - 1; i >= 0; i--)
                {
                    if (M2Share.sSellOffItemList.Count <= 0)
                    {
                        break;
                    }
                    DealOffInfo = M2Share.sSellOffItemList[i];
                    if ((DealOffInfo != null))
                    {
                        if (((DealOffInfo.sDealCharName).ToLower().CompareTo((DealCharName).ToLower()) == 0)
                            && ((DealOffInfo.sBuyCharName).ToLower().CompareTo((this.m_sCharName).ToLower()) == 0) && (DealOffInfo.N == 0))
                        {
                            DealOffInfo.N = 4; // 正在操作中
                            if (m_nGameGold >= (DealOffInfo.nSellGold + M2Share.g_Config.nDecUserGameGold))  // 每次扣多少元宝(元宝寄售)
                            {
                                m_nGameGold -= DealOffInfo.nSellGold + M2Share.g_Config.nDecUserGameGold;// 扣出元宝
                                if (m_nGameGold < 0)
                                {
                                    m_nGameGold = 0;
                                }
                                this.GameGoldChanged();// 更新元宝数量
                                PlayObject = M2Share.UserEngine.GetPlayObject(DealOffInfo.sDealCharName);// 给出售人元宝
                                if (PlayObject == null)// 出售人不在线
                                {
                                    DealOffInfo.N = 1;// 物品已出售,出售人未得到元宝
                                }
                                else
                                {
                                    if (PlayObject.m_boNotOnlineAddExp) // 挂机
                                    {
                                        DealOffInfo.N = 1;// 物品已出售,出售人未得到元宝
                                    }
                                    else
                                    {
                                        UpdateSellOffInfo(1);
                                        DealOffInfo.N = 2;// 交易结束
                                        PlayObject.m_nGameGold += DealOffInfo.nSellGold;
                                        PlayObject.GameGoldChanged();
                                        PlayObject.SysMsg(string.Format(GameMsgDef.sGetSellOffGlod, DealOffInfo.nSellGold), TMsgColor.c_Red, TMsgType.t_Hint);
                                        if (M2Share.g_boGameLogGameGold)
                                        {
                                            M2Share.AddGameDataLog(string.Format(GameMsgDef.g_sGameLogMsg1, M2Share.LOG_GAMEGOLD, PlayObject.m_sMapName,
                                                PlayObject.m_nCurrX, PlayObject.m_nCurrY, PlayObject.m_sCharName, M2Share.g_Config.sGameGoldName,
                                                PlayObject.m_nGameGold, "寄售获得(" + (DealOffInfo.nSellGold).ToString() + ")", this.m_sCharName));
                                        }
                                    }
                                }
                                // FrmDB.SaveSellOffItemList;//保存元宝寄售列表
                                for (int K = 0; K <= 9; K++)
                                {
                                    StdItem = M2Share.UserEngine.GetStdItem(DealOffInfo.UseItems[K].wIndex);
                                    if ((StdItem != null))
                                    {
                                        UserItem = new TUserItem();
                                        UserItem = DealOffInfo.UseItems[K];
                                        if (IsEnoughBag()) // 检查人物的包裹是否满了
                                        {
                                            ClearCopyItem(0, UserItem.wIndex, UserItem.MakeIndex);// 清理包裹和仓库复制物品
                                            if (this.AddItemToBag(UserItem))
                                            {
                                                SendAddItem(UserItem);
                                                if (StdItem.NeedIdentify == 1)
                                                {
                                                    M2Share.AddGameDataLog("9" + "\09" + this.m_sMapName + "(*)" + "\09" + (this.m_nCurrX).ToString()
                                                        + "\09" + (this.m_nCurrY).ToString() + "\09" + this.m_sCharName + "\09" + StdItem.Name + "\09"
                                                        + (UserItem.MakeIndex).ToString() + "\09" + "(" + (HUtil32.LoWord(StdItem.DC)).ToString() + "/"
                                                        + (HUtil32.HiWord(StdItem.DC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MC)).ToString() + "/"
                                                        + (HUtil32.HiWord(StdItem.MC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.SC)).ToString() + "/"
                                                        + (HUtil32.HiWord(StdItem.SC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.AC)).ToString() + "/"
                                                        + (HUtil32.HiWord(StdItem.AC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MAC)).ToString() + "/"
                                                        + (HUtil32.HiWord(StdItem.MAC)).ToString() + ")" + (UserItem.btValue[0]).ToString() + "/" + (UserItem.btValue[1]).ToString()
                                                        + "/" + (UserItem.btValue[2]).ToString() + "/" + (UserItem.btValue[3]).ToString() + "/" + (UserItem.btValue[4]).ToString()
                                                        + "/" + (UserItem.btValue[5]).ToString() + "/" + (UserItem.btValue[6]).ToString() + "/" + (UserItem.btValue[7]).ToString()
                                                        + "/" + (UserItem.btValue[8]).ToString() + "/" + (UserItem.btValue[14]).ToString() + "\09"
                                                        + DealOffInfo.sDealCharName);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            this.DropItemDown(UserItem, 3, false, false, this, this); //包裹没位了,则把物品扔出来
                                        }
                                    }
                                    // 是金刚石
                                    else if ((DealOffInfo.UseItems[K].MakeIndex > 0) && (DealOffInfo.UseItems[K].wIndex == ushort.MaxValue) &&
                                        (DealOffInfo.UseItems[K].Dura == ushort.MaxValue) && (DealOffInfo.UseItems[K].DuraMax == ushort.MaxValue))
                                    {
                                        m_nGAMEDIAMOND += DealOffInfo.UseItems[K].MakeIndex;// 增加金刚石
                                        this.SysMsg(DealOffInfo.UseItems[K].MakeIndex + " 颗金刚石增加", TMsgColor.c_Blue, TMsgType.t_Hint);
                                    }
                                }
                                this.SendMsg(this, Grobal2.RM_SELLOFFBUY_OK, 0, 0, 0, 0, "");// 购买成功
                                this.SendMsg(this, Grobal2.RM_MENU_OK, 0, this.m_ActorsId, 0, 0, "[成功] 系统已经成功接受您的申请");
                                break;
                            }
                            else
                            {
                                DealOffInfo.N = 0;//购买不成功则改为原来的状态
                                this.SendMsg(this, Grobal2.RM_MENU_OK, 0, this.m_ActorsId, 0, 0, "[错误] 您的申请提交不成功");
                                break;
                            }
                        }
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TPlayObject.ClientBuySellOffItme");
            }
        }

        /// <summary>
        /// 客户端取消元宝寄售
        /// </summary>
        private void ClientCancelSellOff()
        {
            SellOffCancel();
        }


        /// <summary>
        /// 客户端元宝寄售结束   
        /// 把临时列表数据写入元宝寄售列表中,并清空临时列表
        /// </summary>
        /// <param name="sBuyCharName">购买者名称</param>
        /// <param name="nSellGold">出售价格</param>
        /// <param name="nGAMEDIAMOND"></param>
        /// <param name="nCode"></param>
        private void ClientSellOffEnd(string sBuyCharName, int nSellGold, int nGAMEDIAMOND, int nCode)
        {
            bool bo11 = false;
            TUserItem UserItem;
            TStdItem StdItem;
            TDealOffInfo DealOffInfo;
            m_boSellOffOK = true;
            if (m_boSellOffOK && ((m_SellOffItemList.Count > 0) || (nGAMEDIAMOND > 0)) && (m_SellOffItemList.Count < 10)
                && (sBuyCharName.Length < Grobal2.ACTORNAMELEN + 1) && (nSellGold > 0) && (nSellGold < 100000) &&
                ((sBuyCharName).ToLower().CompareTo((this.m_sCharName).ToLower()) != 0))  // 不能自己寄售给自己
            {
                DealOffInfo = new TDealOffInfo();
                DealOffInfo.UseItems = new TUserItem[9];
                if (m_SellOffItemList.Count > 0)
                {
                    for (int i = 0; i < m_SellOffItemList.Count; i++)
                    {
                        UserItem = m_SellOffItemList[i];
                        StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                        if ((StdItem != null) && (StdItem.StdMode == 51) && (StdItem.Shape == 0) && (UserItem.Dura > 0) && (UserItem.btValue[20] == 1)) // 是聚灵珠
                        {
                            n_UsesItemTick = 0;// 时间初始
                            UserItem.btValue[12] = 2; // 不能聚集的标识
                        }
                        if ((UserItem != null) && (UserItem.MakeIndex > 0))
                        {
                            DealOffInfo.UseItems[i] = UserItem;
                        }
                    }
                }
                for (int K = 0; K <= 9; K++)
                {
                    StdItem = M2Share.UserEngine.GetStdItem(DealOffInfo.UseItems[K].wIndex);
                    if ((StdItem == null) && (nGAMEDIAMOND > 0) && (nGAMEDIAMOND < 10000) && (nCode == ushort.MaxValue))  // 物品是金刚石
                    {
                        if (nGAMEDIAMOND > m_nGAMEDIAMOND) // 金刚石数量大于玩家的数量时则反回失败
                        {
                            this.SendMsg(this, Grobal2.RM_SELLOFFEND_FAIL, 0, 0, 0, 0, "");
                            this.SendMsg(this, Grobal2.RM_MENU_OK, 0, this.m_ActorsId, 0, 0, "[错误] 你没有那么多" + M2Share.g_Config.sGameDiaMond);
                            GetBackSellOffItems();// 返回物品
                            return;
                        }
                        m_nGAMEDIAMOND -= nGAMEDIAMOND;
                        this.GameGoldChanged();// 更新金刚石数量
                        DealOffInfo.UseItems[K].MakeIndex = nGAMEDIAMOND;// 金刚石数量
                        DealOffInfo.UseItems[K].wIndex = ushort.MaxValue;
                        DealOffInfo.UseItems[K].Dura = ushort.MaxValue;
                        DealOffInfo.UseItems[K].DuraMax = ushort.MaxValue;
                        break;
                    }
                }
                DealOffInfo.sDealCharName = this.m_sCharName;// 寄售人
                DealOffInfo.sBuyCharName = sBuyCharName.Trim();// 购买人
                DealOffInfo.nSellGold = nSellGold;// 元宝数
                DealOffInfo.dSellDateTime = DateTime.Now;// 操作时间
                DealOffInfo.N = 0;// 标识
                M2Share.sSellOffItemList.Add(DealOffInfo);// 增加到元宝寄售列表中
                this.SendMsg(this, Grobal2.RM_SELLOFFEND_OK, 0, 0, 0, 0, "");
                m_nGameGold -= M2Share.g_Config.nDecUserGameGold;// 每次扣多少元宝(元宝寄售) 20080319
                if (m_nGameGold < 0)
                {
                    m_nGameGold = 0;
                }
                this.SendMsg(this, Grobal2.RM_MENU_OK, 0, this.m_ActorsId, 0, 0, "[成功] 系统已经成功接受您的申请");
                bo11 = true;
                // FrmDB.SaveSellOffItemList;//保存元宝寄售列表 20080317
                m_boSellOffOK = false;
                m_SellOffItemList.Clear();
            }
            if (!bo11)// 失败则返回物品给玩家
            {
                this.SendMsg(this, Grobal2.RM_SELLOFFEND_FAIL, 0, 0, 0, 0, "");
                this.SendMsg(this, Grobal2.RM_MENU_OK, 0, this.m_ActorsId, 0, 0, "[错误:] 寄售物品失败");
                GetBackSellOffItems();
            }
        }

        /// <summary>
        /// 客户端增加交易物品到交易框中
        /// </summary>
        /// <param name="nItemIdx"></param>
        /// <param name="sItemName"></param>
        private void ClientAddDealItem(int nItemIdx, string sItemName)
        {
            bool bo11;
            TUserItem UserItem;
            string sUserItemName;
            if ((m_DealCreat == null) || !m_boDealing)
            {
                return;
            }
            m_boCanQueryBag = true;// 交易增加物品时,不能刷新包裹
            try
            {
                if (sItemName.IndexOf(" ") >= 0)// 折分物品名称(信件物品的名称后面加了使用次数)
                {
                    HUtil32.GetValidStr3(sItemName, ref sItemName, new string[] { " " });
                }
                bo11 = false;
                if (!m_DealCreat.m_boDealOK)
                {
                    for (int i = this.m_ItemList.Count - 1; i >= 0; i--)
                    {
                        if (this.m_ItemList.Count <= 0)
                        {
                            break;
                        }
                        UserItem = this.m_ItemList[i];
                        if (UserItem == null)
                        {
                            continue;
                        }
                        if (UserItem.MakeIndex == nItemIdx)
                        {
                            sUserItemName = ""; // 取自定义物品名称
                            if (UserItem.btValue[13] == 1)
                            {
                                sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                            }
                            if (sUserItemName == "")
                            {
                                sUserItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                            }
                            if (((sUserItemName).ToLower().CompareTo((sItemName).ToLower()) == 0) && (m_DealItemList.Count < 12))
                            {
                                if (this.CheckItemValue(UserItem, 1)) // 禁止交易
                                {
                                    break;
                                }
                                else if (this.PlugOfCheckCanItem(1, sUserItemName, false, 0, 0))// 禁止物品规则(管理插件功能)
                                {
                                    break;
                                }
                                m_DealItemList.Add(UserItem);
                                ((this) as TPlayObject).SendAddDealItem(UserItem);
                                this.m_ItemList.RemoveAt(i);
                                ClearCopyItem(0, UserItem.wIndex, UserItem.MakeIndex);// 清理包裹和仓库复制物品
                                bo11 = true;
                                break;
                            }
                        }
                    }
                }
                if (!bo11)
                {
                    SendDefMessage(Grobal2.SM_DEALADDITEM_FAIL, 0, 0, 0, 0, "");
                }
            }
            finally
            {
                m_boCanQueryBag = false;// 交易增加物品时,不能刷新包裹
            }
        }

        /// <summary>
        /// 客户端删除交易物品
        /// </summary>
        /// <param name="nItemIdx"></param>
        /// <param name="sItemName"></param>
        private void ClientDelDealItem(int nItemIdx, string sItemName)
        {
            bool bo11;
            TUserItem UserItem;
            string sUserItemName;
            if (M2Share.g_Config.boCanNotGetBackDeal)// 禁止取回物品
            {
                this.SendMsg(M2Share.g_ManageNPC, Grobal2.RM_MENU_OK, 0, this.m_ActorsId, 0, 0, GameMsgDef.g_sDealItemsDenyGetBackMsg);
                SendDefMessage(Grobal2.SM_DEALDELITEM_FAIL, 0, 0, 0, 0, "");
                return;
            }
            if ((m_DealCreat == null) || !m_boDealing)
            {
                return;
            }
            if (sItemName.IndexOf(" ") >= 0)// 折分物品名称(信件物品的名称后面加了使用次数)
            {
                HUtil32.GetValidStr3(sItemName, ref sItemName, new string[] { " " });
            }
            bo11 = false;
            if (!m_DealCreat.m_boDealOK)
            {
                for (int i = m_DealItemList.Count - 1; i >= 0; i--)
                {
                    if (m_DealItemList.Count <= 0)
                    {
                        break;
                    }
                    UserItem = m_DealItemList[i];
                    if (UserItem == null)
                    {
                        continue;
                    }
                    if (UserItem.MakeIndex == nItemIdx)
                    {
                        sUserItemName = "";// 取自定义物品名称
                        if (UserItem.btValue[13] == 1)
                        {
                            sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                        }
                        if (sUserItemName == "")
                        {
                            sUserItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                        }
                        if ((sUserItemName).ToLower().CompareTo((sItemName).ToLower()) == 0)
                        {
                            this.m_ItemList.Add(UserItem);
                            this.SendDelDealItem(UserItem);
                            m_DealItemList.RemoveAt(i);
                            bo11 = true;
                            break;
                        }
                    }
                }
            }
            if (!bo11)
            {
                SendDefMessage(Grobal2.SM_DEALDELITEM_FAIL, 0, 0, 0, 0, "");
            }
        }

        /// <summary>
        /// 客户端取消交易
        /// </summary>
        private void ClientCancelDeal()
        {
            DealCancel();
        }

        /// <summary>
        /// 客户端把金币放到交易框中
        /// </summary>
        /// <param name="nGold"></param>
        private void ClientChangeDealGold(int nGold)
        {
            bool bo09;
            if ((m_nDealGolds > 0) && M2Share.g_Config.boCanNotGetBackDeal) // 禁止取回放入交易栏内的金币
            {
                this.SendMsg(M2Share.g_ManageNPC, Grobal2.RM_MENU_OK, 0, this.m_ActorsId, 0, 0, GameMsgDef.g_sDealItemsDenyGetBackMsg);
                SendDefMessage(Grobal2.SM_DEALDELITEM_FAIL, 0, 0, 0, 0, "");
                return;
            }
            if (nGold < 0)
            {
                SendDefMessage(Grobal2.SM_DEALCHGGOLD_FAIL, m_nDealGolds, HUtil32.LoWord(this.m_nGold), HUtil32.HiWord(this.m_nGold), 0, "");
                return;
            }
            bo09 = false;
            if ((m_DealCreat != null) && (this.GetPoseCreate() == m_DealCreat))
            {
                if (!m_DealCreat.m_boDealOK)
                {
                    if ((this.m_nGold + m_nDealGolds) >= nGold)
                    {
                        this.m_nGold = (this.m_nGold + m_nDealGolds) - nGold;
                        m_nDealGolds = nGold;
                        SendDefMessage(Grobal2.SM_DEALCHGGOLD_OK, m_nDealGolds, HUtil32.LoWord(this.m_nGold), HUtil32.HiWord(this.m_nGold), 0, "");
                        m_DealCreat.SendDefMessage(Grobal2.SM_DEALREMOTECHGGOLD, m_nDealGolds, 0, 0, 0, "");
                        m_DealCreat.m_DealLastTick = HUtil32.GetTickCount();
                        bo09 = true;
                        m_DealLastTick = HUtil32.GetTickCount();
                    }
                }
            }
            if (!bo09)
            {
                SendDefMessage(Grobal2.SM_DEALCHGGOLD_FAIL, m_nDealGolds, (ushort)HUtil32.LoWord(this.m_nGold), (ushort)HUtil32.HiWord(this.m_nGold), 0, "");
            }
        }

        /// <summary>
        /// 交易结束
        /// </summary>
        private void ClientDealEnd()
        {
            bool bo11;
            TUserItem UserItem;
            TStdItem StdItem;
            TPlayObject PlayObject;
            m_boDealOK = true;
            if (m_DealCreat == null)
            {
                return;
            }
            if (((HUtil32.GetTickCount() - m_DealLastTick) < M2Share.g_Config.dwDealOKTime) || ((HUtil32.GetTickCount() - m_DealCreat.m_DealLastTick) < M2Share.g_Config.dwDealOKTime))
            {
                this.SysMsg(GameMsgDef.g_sDealOKTooFast, TMsgColor.c_Red, TMsgType.t_Hint);
                DealCancel();
                return;
            }
            if (m_DealCreat.m_boDealOK)
            {
                bo11 = true;
                if ((Grobal2.MAXBAGITEM - this.m_ItemList.Count) < m_DealCreat.m_DealItemList.Count)
                {
                    bo11 = false;
                    this.SysMsg(GameMsgDef.g_sYourBagSizeTooSmall, TMsgColor.c_Red, TMsgType.t_Hint);
                }
                if ((this.m_nGoldMax - this.m_nGold) < m_DealCreat.m_nDealGolds)
                {
                    this.SysMsg(GameMsgDef.g_sYourGoldLargeThenLimit, TMsgColor.c_Red, TMsgType.t_Hint);
                    bo11 = false;
                }
                if ((Grobal2.MAXBAGITEM - m_DealCreat.m_ItemList.Count) < m_DealItemList.Count)
                {
                    this.SysMsg(GameMsgDef.g_sDealHumanBagSizeTooSmall, TMsgColor.c_Red, TMsgType.t_Hint);
                    bo11 = false;
                }
                if ((m_DealCreat.m_nGoldMax - m_DealCreat.m_nGold) < m_nDealGolds)
                {
                    this.SysMsg(GameMsgDef.g_sDealHumanGoldLargeThenLimit, TMsgColor.c_Red, TMsgType.t_Hint);
                    bo11 = false;
                }
                if (bo11)
                {
                    if (m_DealItemList.Count > 0)
                    {
                        for (int i = 0; i < m_DealItemList.Count; i++)
                        {
                            UserItem = m_DealItemList[i];
                            StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                            if ((StdItem != null) && (StdItem.StdMode == 51) && (StdItem.Shape == 0) && (UserItem.Dura > 0)
                                && (UserItem.btValue[20] == 1))// 是聚灵珠
                            {
                                n_UsesItemTick = 0;// 时间初始
                                UserItem.btValue[12] = 2;// 不能聚集的标识
                            }
                            m_DealCreat.ClearCopyItem(0, UserItem.wIndex, UserItem.MakeIndex);// 清理包裹和仓库复制物品
                            m_DealCreat.AddItemToBag(UserItem);
                            m_DealCreat.SendAddItem(UserItem);
                            if (StdItem != null)
                            {
                                if (StdItem.NeedIdentify == 1)
                                {
                                    M2Share.AddGameDataLog("8" + "\09" + this.m_sMapName + "\09" + (this.m_nCurrX).ToString() + "\09"
                                        + (this.m_nCurrY).ToString() + "\09" + this.m_sCharName + "\09" + StdItem.Name + "\09" + (UserItem.MakeIndex).ToString()
                                        + "\09" + "(" + (HUtil32.LoWord(StdItem.DC)).ToString() + "/" + (HUtil32.HiWord(StdItem.DC)).ToString() + ")" + "("
                                        + (HUtil32.LoWord(StdItem.MC)).ToString() + "/" + (HUtil32.HiWord(StdItem.MC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.SC)).ToString()
                                        + "/" + (HUtil32.HiWord(StdItem.SC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.AC)).ToString() + "/"
                                        + (HUtil32.HiWord(StdItem.AC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MAC)).ToString() + "/"
                                        + (HUtil32.HiWord(StdItem.MAC)).ToString() + ")" + (UserItem.btValue[0]).ToString() + "/" + (UserItem.btValue[1]).ToString() + "/"
                                        + (UserItem.btValue[2]).ToString() + "/" + (UserItem.btValue[3]).ToString() + "/" + (UserItem.btValue[4]).ToString() + "/"
                                        + (UserItem.btValue[5]).ToString() + "/" + (UserItem.btValue[6]).ToString() + "/" + (UserItem.btValue[7]).ToString() + "/"
                                        + (UserItem.btValue[8]).ToString() + "/" + (UserItem.btValue[14]).ToString() + "\09" + m_DealCreat.m_sCharName);
                                }
                            }
                        }
                    }
                    if (m_nDealGolds > 0)
                    {
                        m_DealCreat.m_nGold += m_nDealGolds;
                        m_DealCreat.GoldChanged();
                        if (M2Share.g_boGameLogGold)
                        {
                            M2Share.AddGameDataLog("8" + "\09" + this.m_sMapName + "\09" + this.m_nCurrX + "\09" + this.m_nCurrY
                                + "\09" + this.m_sCharName + "\09" + M2Share.sSTRING_GOLDNAME + "\09" + this.m_nGold + "\09" + "1" + "\09" + m_DealCreat.m_sCharName);
                        }
                    }
                    if (m_DealCreat.m_DealItemList.Count > 0)
                    {
                        for (int i = 0; i < m_DealCreat.m_DealItemList.Count; i++)
                        {
                            UserItem = m_DealCreat.m_DealItemList[i];
                            StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                            if ((StdItem != null) && (StdItem.StdMode == 51) && (StdItem.Shape == 0) && (UserItem.Dura > 0)
                                && (UserItem.btValue[20] == 1))// 是聚灵珠
                            {
                                m_DealCreat.n_UsesItemTick = 0;// 时间初始
                                UserItem.btValue[12] = 2;// 不能聚集的标识
                            }
                            ClearCopyItem(0, UserItem.wIndex, UserItem.MakeIndex);// 清理包裹和仓库复制物品
                            this.AddItemToBag(UserItem);
                            ((this) as TPlayObject).SendAddItem(UserItem);
                            if (StdItem != null)
                            {
                                if (StdItem.NeedIdentify == 1)
                                {
                                    M2Share.AddGameDataLog("8" + "\09" + m_DealCreat.m_sMapName + "\09" + (m_DealCreat.m_nCurrX).ToString()
                                        + "\09" + (m_DealCreat.m_nCurrY).ToString() + "\09" + m_DealCreat.m_sCharName + "\09" + StdItem.Name
                                        + "\09" + (UserItem.MakeIndex).ToString() + "\09" + "(" + (HUtil32.LoWord(StdItem.DC)).ToString()
                                        + "/" + (HUtil32.HiWord(StdItem.DC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MC)).ToString()
                                        + "/" + (HUtil32.HiWord(StdItem.MC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.SC)).ToString()
                                        + "/" + (HUtil32.HiWord(StdItem.SC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.AC)).ToString()
                                        + "/" + (HUtil32.HiWord(StdItem.AC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MAC)).ToString()
                                        + "/" + (HUtil32.HiWord(StdItem.MAC)).ToString() + ")" + (UserItem.btValue[0]).ToString() + "/"
                                        + (UserItem.btValue[1]).ToString() + "/" + (UserItem.btValue[2]).ToString() + "/" + (UserItem.btValue[3]).ToString()
                                        + "/" + (UserItem.btValue[4]).ToString() + "/" + (UserItem.btValue[5]).ToString() + "/" + (UserItem.btValue[6]).ToString()
                                        + "/" + (UserItem.btValue[7]).ToString() + "/" + (UserItem.btValue[8]).ToString() + "/" + (UserItem.btValue[14]).ToString()
                                        + "\09" + this.m_sCharName);
                                }
                            }
                        }
                    }
                    if (m_DealCreat.m_nDealGolds > 0)
                    {
                        this.m_nGold += m_DealCreat.m_nDealGolds;
                        this.GoldChanged();
                        if (M2Share.g_boGameLogGold)
                        {
                            M2Share.AddGameDataLog("8" + "\09" + m_DealCreat.m_sMapName + "\09" + (m_DealCreat.m_nCurrX).ToString()
                                + "\09" + (m_DealCreat.m_nCurrY).ToString() + "\09" + m_DealCreat.m_sCharName + "\09" + M2Share.sSTRING_GOLDNAME
                                + "\09" + (m_DealCreat.m_nGold).ToString() + "\09" + "1" + "\09" + this.m_sCharName);
                        }
                    }
                    PlayObject = m_DealCreat;
                    PlayObject.SendDefMessage(Grobal2.SM_DEALSUCCESS, 0, 0, 0, 0, "");// '交易成功...'
                    PlayObject.SysMsg(GameMsgDef.g_sDealSuccessMsg, TMsgColor.c_Green, TMsgType.t_Hint);
                    PlayObject.m_DealCreat = null;
                    PlayObject.m_boDealing = false;
                    PlayObject.m_DealItemList.Clear();
                    PlayObject.m_nDealGolds = 0;
                    PlayObject.m_boDealOK = false;
                    SendDefMessage(Grobal2.SM_DEALSUCCESS, 0, 0, 0, 0, "");// '交易成功...'
                    this.SysMsg(GameMsgDef.g_sDealSuccessMsg, TMsgColor.c_Green, TMsgType.t_Hint);
                    m_DealCreat = null;
                    m_boDealing = false;
                    m_DealItemList.Clear();
                    m_nDealGolds = 0;
                    m_boDealOK = false;
                }
                else
                {
                    DealCancel();
                }
            }
            else
            {
                this.SysMsg(GameMsgDef.g_sYouDealOKMsg, TMsgColor.c_Green, TMsgType.t_Hint); // '你已经确认交易了'
                m_DealCreat.SysMsg(GameMsgDef.g_sPoseDealOKMsg, TMsgColor.c_Green, TMsgType.t_Hint);// '对方已经确认交易了'
            }
        }

        /// <summary>
        /// 客户端获取小地图
        /// </summary>
        private void ClientGetMinMap()
        {
            int nMinMap = this.m_PEnvir.nMinMap;
            if (nMinMap > 0)
            {
                SendDefMessage(Grobal2.SM_READMINIMAP_OK, 0, (ushort)nMinMap, 0, 0, "");
            }
            else
            {
                SendDefMessage(Grobal2.SM_READMINIMAP_FAIL, 0, 0, 0, 0, "");
            }
        }

        /// <summary>
        /// 客户端取制造的药品
        /// </summary>
        private void ClientMakeDrugItem(int NPC, string nItemName)
        {
            TMerchant Merchant = (TMerchant)M2Share.UserEngine.FindMerchant(NPC);
            if ((Merchant == null) || (!Merchant.m_boMakeDrug))
            {
                return;
            }
            if (((Merchant.m_PEnvir == this.m_PEnvir) && (Math.Abs(Merchant.m_nCurrX - this.m_nCurrX) < 15) && (Math.Abs(Merchant.m_nCurrY - this.m_nCurrY) < 15)))
            {
                Merchant.ClientMakeDrugItem(this, nItemName);
            }
        }

        /// <summary>
        /// 客户端打开行会对话框
        /// </summary>
        private void ClientOpenGuildDlg()
        {
            string SC;
            if (this.m_MyGuild != null)
            {
                SC = this.m_MyGuild.sGuildName + '\r' + " " + '\r';
                if (this.m_nGuildRankNo == 1)
                {
                    SC = SC + "1" + '\r';
                }
                else
                {
                    SC = SC + "0" + '\r';
                }
                SC = SC + "<Notice>" + '\r';
                if (this.m_MyGuild.NoticeList.Count > 0)
                {
                    for (int i = 0; i < this.m_MyGuild.NoticeList.Count; i++)
                    {
                        if (SC.Length > 5000)
                        {
                            break;
                        }
                        SC = SC + this.m_MyGuild.NoticeList[i] + '\r';
                    }
                }
                SC = SC + "<KillGuilds>" + '\r';
                if (this.m_MyGuild.GuildWarList.Count > 0)
                {
                    for (int i = 0; i < this.m_MyGuild.GuildWarList.Count; i++)
                    {
                        if (SC.Length > 5000)
                        {
                            break;
                        }
                        SC = SC + this.m_MyGuild.GuildWarList[i] + '\r';
                    }
                }
                SC = SC + "<AllyGuilds>" + '\r';
                if (this.m_MyGuild.GuildAllList.Count > 0)
                {
                    for (int i = 0; i < this.m_MyGuild.GuildAllList.Count; i++)
                    {
                        if (SC.Length > 5000)
                        {
                            break;
                        }
                        SC = SC + this.m_MyGuild.GuildAllList[i] + '\r';
                    }
                }
                this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_OPENGUILDDLG, 0, 0, 0, 1, 0);
                SendSocket(this.m_DefMsg, EncryptUnit.EncodeString(SC));
            }
            else
            {
                SendDefMessage(Grobal2.SM_OPENGUILDDLG_FAIL, 0, 0, 0, 0, "");
            }
        }

        /// <summary>
        /// 客户端打开行会
        /// </summary>
        private void ClientGuildHome()
        {
            ClientOpenGuildDlg();
        }

        /// <summary>
        /// 客户端获取行会成员列表
        /// </summary>
        private void ClientGuildMemberList()
        {
            TGuildRank GuildRank;
            string sSENDMSG = string.Empty;
            if (this.m_MyGuild == null)
            {
                return;
            }
            if (this.m_MyGuild.m_RankList.Count > 0)
            {
                for (int i = 0; i < this.m_MyGuild.m_RankList.Count; i++)
                {
                    GuildRank = this.m_MyGuild.m_RankList[i];
                    if (GuildRank == null)
                    {
                        continue;
                    }
                    sSENDMSG = sSENDMSG + "#" + GuildRank.nRankNo + "/*" + GuildRank.sRankName + "/";
                    if (GuildRank.MemberList.Count > 0)
                    {
                        for (int j = 0; j < GuildRank.MemberList.Count; j++)
                        {
                            if (sSENDMSG.Length > 5000)
                            {
                                break;
                            }
                            sSENDMSG = sSENDMSG + GuildRank.MemberList[j] + "/";
                        }
                    }
                }
            }
            this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_SENDGUILDMEMBERLIST, 0, 0, 0, 1, 0);
            SendSocket(this.m_DefMsg, EncryptUnit.EncodeString(sSENDMSG));
        }

        /// <summary>
        /// 客户端行会增加成员
        /// </summary>
        /// <param name="sHumName"></param>
        private void ClientGuildAddMember(string sHumName)
        {
            int result;
            TPlayObject PlayObject;
            result = 1;// '你没有权利使用这个命令。'
            if (this.IsGuildMaster())
            {
                PlayObject = M2Share.UserEngine.GetPlayObject(sHumName);
                if ((PlayObject != null) && (!PlayObject.m_boNotOnlineAddExp)) //增加检测不是离线挂机人物
                {
                    if ((PlayObject.GetPoseCreate() == this) && (PlayObject.GetPoseCreate() != null))
                    {
                        if (PlayObject.m_boAllowGuild)
                        {
                            if (!this.m_MyGuild.IsMember(sHumName))
                            {
                                if ((PlayObject.m_MyGuild == null) && (this.m_MyGuild.m_RankList.Count < this.m_MyGuild.GuildMemberCount))
                                {
                                    this.m_MyGuild.AddMember(PlayObject);
                                    M2Share.UserEngine.SendServerGroupMsg(Grobal2.SS_207, M2Share.nServerIndex, this.m_MyGuild.sGuildName);
                                    PlayObject.m_MyGuild = this.m_MyGuild;
                                    PlayObject.m_sGuildRankName = this.m_MyGuild.GetRankName(PlayObject, ref PlayObject.m_nGuildRankNo);
                                    PlayObject.RefShowName();
                                    PlayObject.SysMsg("您已加入行会: " + this.m_MyGuild.sGuildName + " 当前封号为: " +
                                        PlayObject.m_sGuildRankName, TMsgColor.c_Green, TMsgType.t_Hint);
                                    result = 0;
                                }
                                else
                                {
                                    result = 4; // '对方已经加入其他行会。'
                                }
                            }
                            else
                            {
                                result = 3;// '对方已经加入我们的行会。'
                            }
                        }
                        else
                        {
                            result = 5;// '对方不允许加入行会。'
                            PlayObject.SysMsg("您拒绝加入行会。 [允许命令为 @" + M2Share.g_GameCommand.LETGUILD.sCmd + "]", TMsgColor.c_Red, TMsgType.t_Hint);
                        }
                    }
                    else
                    {
                        result = 2;// '想加入行会的应该来面对行会掌门人'
                    }
                }
                else
                {
                    result = 2;
                }
            }
            if (result == 0)
            {
                SendDefMessage(Grobal2.SM_GUILDADDMEMBER_OK, 0, 0, 0, 0, "");
            }
            else
            {
                SendDefMessage(Grobal2.SM_GUILDADDMEMBER_FAIL, result, 0, 0, 0, "");
            }
        }

        /// <summary>
        /// 客户端行会删除成员
        /// </summary>
        /// <param name="sHumName"></param>
        private void ClientGuildDelMember(string sHumName)
        {
            int nC;
            string s14;
            TPlayObject PlayObject;
            nC = 1;
            if (this.IsGuildMaster())
            {
                if (this.m_MyGuild.IsMember(sHumName))
                {
                    if (this.m_sCharName != sHumName)
                    {
                        if (this.m_MyGuild.DelMember(sHumName))
                        {
                            PlayObject = M2Share.UserEngine.GetPlayObject(sHumName);
                            if (PlayObject != null)
                            {
                                PlayObject.m_MyGuild = null;
                                PlayObject.RefRankInfo(0, "");
                                PlayObject.RefShowName();
                            }
                            M2Share.UserEngine.SendServerGroupMsg(Grobal2.SS_207, M2Share.nServerIndex, ((TGUild)(this.m_MyGuild)).sGuildName);
                            nC = 0;
                        }
                        else
                        {
                            nC = 4;
                        }
                    }
                    else
                    {
                        nC = 3;
                        s14 = this.m_MyGuild.sGuildName;
                        if (this.m_MyGuild.CancelGuld(sHumName))
                        {
                            M2Share.g_GuildManager.DelGuild(s14);
                            M2Share.UserEngine.SendServerGroupMsg(Grobal2.SS_206, M2Share.nServerIndex, s14);
                            this.m_MyGuild = null;
                            RefRankInfo(0, "");
                            this.RefShowName();
                            this.SysMsg("行会" + s14 + "已被取消！！！", TMsgColor.c_Red, TMsgType.t_Hint);
                            nC = 0;
                        }
                    }
                }
                else
                {
                    nC = 2;
                }
            }
            if (nC == 0)
            {
                SendDefMessage(Grobal2.SM_GUILDDELMEMBER_OK, 0, 0, 0, 0, "");
            }
            else
            {
                SendDefMessage(Grobal2.SM_GUILDDELMEMBER_FAIL, nC, 0, 0, 0, "");
            }
        }

        /// <summary>
        /// 客户端行会更新公告
        /// </summary>
        /// <param name="sNotict"></param>
        private void ClientGuildUpdateNotice(string sNotict)
        {
            string SC = string.Empty;
            if ((this.m_MyGuild == null) || (this.m_nGuildRankNo != 1))
            {
                return;
            }
            this.m_MyGuild.NoticeList.Clear();
            while ((sNotict != ""))
            {
                sNotict = HUtil32.GetValidStr3(sNotict, ref SC, new string[] { "\r" });
                this.m_MyGuild.NoticeList.Add(SC);
            }
            this.m_MyGuild.SaveGuildInfoFile();
            M2Share.UserEngine.SendServerGroupMsg(Grobal2.SS_207, M2Share.nServerIndex, this.m_MyGuild.sGuildName);
            ClientOpenGuildDlg();
        }

        /// <summary>
        /// 修改行会成员封号,等级
        /// </summary>
        /// <param name="sRankInfo"></param>
        private void ClientGuildUpdateRankInfo(string sRankInfo)
        {
            if ((this.m_MyGuild == null) || (this.m_nGuildRankNo != 1)) // 没有行会或不是行会老大则退出
            {
                return;
            }
            int Rank = this.m_MyGuild.UpdateRank(sRankInfo);
            if (Rank == 0)
            {
                M2Share.UserEngine.SendServerGroupMsg(Grobal2.SS_207, M2Share.nServerIndex, this.m_MyGuild.sGuildName);
                ClientGuildMemberList();
            }
            else
            {
                if (Rank <= -2)
                {
                    SendDefMessage(Grobal2.SM_GUILDRANKUPDATE_FAIL, Rank, 0, 0, 0, "");
                }
            }
        }

        // 行会联盟
        private void ClientGuildAlly()
        {
            int n8;
            int nCode;
            TBaseObject BaseObjectC;
            const string sExceptionMsg = "[异常] TPlayObject::ClientGuildAlly {0}";
            nCode = 1;
            try
            {
                n8 = -1;
                BaseObjectC = this.GetPoseCreate();
                nCode = 2;
                if ((BaseObjectC != null) && (BaseObjectC.m_MyGuild != null) && (BaseObjectC.m_btRaceServer == Grobal2.RC_PLAYOBJECT) && (BaseObjectC.GetPoseCreate() == this))
                {
                    if (BaseObjectC.m_MyGuild != null && BaseObjectC.m_MyGuild.m_boEnableAuthAlly)
                    {
                        nCode = 3;
                        if (BaseObjectC.IsGuildMaster() && this.IsGuildMaster())
                        {
                            nCode = 4;
                            if (this.m_MyGuild != null && this.m_MyGuild.IsNotWarGuild(BaseObjectC.m_MyGuild) && BaseObjectC.m_MyGuild.IsNotWarGuild(this.m_MyGuild))
                            {
                                nCode = 6;
                                this.m_MyGuild.AllyGuild(BaseObjectC.m_MyGuild);
                                nCode = 7;
                                BaseObjectC.m_MyGuild.AllyGuild(this.m_MyGuild);
                                nCode = 8;
                                this.m_MyGuild.SendGuildMsg(BaseObjectC.m_MyGuild.sGuildName + "行会已经和您的行会联盟成功。");
                                nCode = 9;
                                BaseObjectC.m_MyGuild.SendGuildMsg(this.m_MyGuild.sGuildName + "行会已经和您的行会联盟成功。");
                                nCode = 10;
                                this.m_MyGuild.RefMemberName();
                                nCode = 11;
                                BaseObjectC.m_MyGuild.RefMemberName();
                                nCode = 12;
                                M2Share.UserEngine.SendServerGroupMsg(Grobal2.SS_207, M2Share.nServerIndex, this.m_MyGuild.sGuildName);
                                nCode = 13;
                                M2Share.UserEngine.SendServerGroupMsg(Grobal2.SS_207, M2Share.nServerIndex, BaseObjectC.m_MyGuild.sGuildName);
                                nCode = 14;
                                n8 = 0;
                            }
                            else
                            {
                                n8 = -2;
                            }
                        }
                        else
                        {
                            n8 = -3;
                        }
                    }
                    else
                    {
                        n8 = -4;
                    }
                }
                if (n8 == 0)
                {
                    SendDefMessage(Grobal2.SM_GUILDMAKEALLY_OK, 0, 0, 0, 0, "");
                }
                else
                {
                    SendDefMessage(Grobal2.SM_GUILDMAKEALLY_FAIL, n8, 0, 0, 0, "");
                }
            }
            catch
            {
                M2Share.MainOutMessage(string.Format(sExceptionMsg, nCode));
            }
        }

        private void ClientGuildBreakAlly(string sGuildName)
        {
            int n10;
            if (!this.IsGuildMaster())
            {
                return;
            }
            TGUild Guild = M2Share.g_GuildManager.FindGuild(sGuildName);
            if ((Guild != null) && (this.m_MyGuild != null))
            {
                if (this.m_MyGuild.IsAllyGuild(Guild))
                {
                    this.m_MyGuild.DelAllyGuild(Guild);
                    Guild.DelAllyGuild(this.m_MyGuild);
                    this.m_MyGuild.SendGuildMsg(Guild.sGuildName + " 行会与您的行会解除联盟成功！！！");
                    Guild.SendGuildMsg(this.m_MyGuild.sGuildName + " 行会解除了与您行会的联盟！！！");
                    this.m_MyGuild.RefMemberName();
                    Guild.RefMemberName();
                    M2Share.UserEngine.SendServerGroupMsg(Grobal2.SS_207, M2Share.nServerIndex, this.m_MyGuild.sGuildName);
                    M2Share.UserEngine.SendServerGroupMsg(Grobal2.SS_207, M2Share.nServerIndex, Guild.sGuildName);
                    n10 = 0;
                }
                else
                {
                    n10 = -2;
                }
            }
            else
            {
                n10 = -3;
            }
            if (n10 == 0)
            {
                SendDefMessage(Grobal2.SM_GUILDBREAKALLY_OK, 0, 0, 0, 0, "");
            }
            else
            {
                SendDefMessage(Grobal2.SM_GUILDMAKEALLY_FAIL, 0, 0, 0, 0, "");
            }
        }

        private void ClientAdjustBonus(int nPoint, string sMsg)
        {
            TNakedAbility BonusAbil;
            int nTotleUsePoint = 0;
            //FillChar(BonusAbil, sizeof(TNakedAbility), '\0');
            //DecodeBuffer(sMsg, BonusAbil, sizeof(TNakedAbility));
            //nTotleUsePoint = BonusAbil.DC + BonusAbil.MC + BonusAbil.SC + BonusAbil.AC + BonusAbil.MAC + BonusAbil.HP + BonusAbil.MP + BonusAbil.Hit + BonusAbil.Speed + BonusAbil.X2;
            if (((nPoint + nTotleUsePoint) == this.m_nBonusPoint) && (this.m_nBonusPoint > 0) && (nPoint >= 0) && (this.m_nBonusPoint >= nPoint))
            {
                if (nTotleUsePoint > 0)
                {
                    BonusAbil = new TNakedAbility();
                    this.m_nBonusPoint = nPoint;
                    this.m_BonusAbil.DC += BonusAbil.DC;
                    this.m_BonusAbil.MC += BonusAbil.MC;
                    this.m_BonusAbil.SC += BonusAbil.SC;
                    this.m_BonusAbil.AC += BonusAbil.AC;
                    this.m_BonusAbil.MAC += BonusAbil.MAC;
                    this.m_BonusAbil.HP += BonusAbil.HP;
                    this.m_BonusAbil.MP += BonusAbil.MP;
                    this.m_BonusAbil.Hit += BonusAbil.Hit;
                    this.m_BonusAbil.Speed += BonusAbil.Speed;
                    this.m_BonusAbil.X2 += BonusAbil.X2;
                    RecalcAbilitys();
                    this.CompareSuitItem(false); //套装与身上装备对比
                    this.SendMsg(this, Grobal2.RM_ABILITY, 0, 0, 0, 0, "");
                    this.SendMsg(this, Grobal2.RM_SUBABILITY, 0, 0, 0, 0, "");
                }
            }
            else
            {
                this.SysMsg("非法数据调整！！！", TMsgColor.c_Red, TMsgType.t_Hint);
            }
        }


        // -----------------------------------宝箱系统-----------------------------------
        // 判断宝箱和钥匙是否对应
        // str为客户端传来的钥匙makeidx
        public unsafe void ClientSendBoxItem(int BoxsIdx, string str)
        {
            TUserItem UserItem = null;
            TStdItem StdItemBox = null;
            TStdItem StdItemKey = null;
            int KeysIdx = Convert.ToInt32(str.Trim());
            if (!this.m_boDeath)
            {
                if (IsEnoughBag())
                {
                    // 包裹不满时
                    if (this.m_ItemList.Count > 0)
                    {
                        for (var i = this.m_ItemList.Count - 1; i >= 0; i--)
                        {
                            if (this.m_ItemList.Count <= 0)
                            {
                                break;
                            }
                            UserItem = this.m_ItemList[i];
                            if (UserItem == null)
                            {
                                continue;
                            }
                            if ((UserItem != null) && (UserItem.MakeIndex == BoxsIdx))// 得到宝箱
                            {
                                StdItemBox = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                if ((StdItemBox != null) && (StdItemBox.StdMode == 48))
                                {
                                    break;
                                }
                            }
                        }
                        for (var i = this.m_ItemList.Count - 1; i >= 0; i--)
                        {
                            if (this.m_ItemList.Count <= 0)
                            {
                                break;
                            }
                            UserItem = this.m_ItemList[i];
                            if (UserItem == null)
                            {
                                continue;
                            }
                            if ((UserItem != null) && (UserItem.MakeIndex == KeysIdx))
                            {
                                // 得到钥匙
                                StdItemKey = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                if ((StdItemKey != null) && (StdItemKey.StdMode == 49))
                                {
                                    break;
                                }
                            }
                        }
                    }
                    if ((StdItemBox != null) && (StdItemKey != null) && (StdItemBox.AniCount == StdItemKey.Shape))  // 宝箱和钥匙对应,则打开宝箱,删除物品
                    {
                        if (ClientOpenBoxs(StdItemBox.Source)) // 宝箱开启
                        {
                            for (var i = this.m_ItemList.Count - 1; i >= 0; i--)// 删除物品
                            {
                                if (this.m_ItemList.Count <= 0)
                                {
                                    break;
                                }
                                UserItem = this.m_ItemList[i];
                                if (UserItem == null)
                                {
                                    continue;
                                }
                                if ((UserItem != null))
                                {
                                    if ((UserItem.MakeIndex == BoxsIdx))
                                    {
                                        if (StdItemBox.NeedIdentify == 1)
                                        {
                                            M2Share.AddGameDataLog("11" + "\09" + this.m_sMapName + "\09" + this.m_nCurrX + "\09" + this.m_nCurrY + "\09" + this.m_sCharName
                                                + "\09" + StdItemBox.Name + "\09" + (UserItem.MakeIndex).ToString() + "\09" + "(开宝箱)" + "\09" + "0");
                                        }
                                        this.m_ItemList.RemoveAt(i);
                                    }
                                    else if ((UserItem.MakeIndex == KeysIdx))
                                    {
                                        if (StdItemKey.NeedIdentify == 1)
                                        {
                                            M2Share.AddGameDataLog("11" + "\09" + this.m_sMapName + "\09" + (this.m_nCurrX).ToString() + "\09" + (this.m_nCurrY).ToString() + "\09" + this.m_sCharName
                                                + "\09" + StdItemBox.Name + "\09" + (UserItem.MakeIndex).ToString() + "\09" + "(开宝箱)" + "\09" + "0");
                                        }
                                        this.m_ItemList.RemoveAt(i);
                                    }
                                }
                            }
                        }
                        else
                        {
                            this.SendMsg(this, Grobal2.RM_OPENBOXS_FAIL, 0, 0, 0, 0, "");// 失败
                            this.SysMsg("开启宝箱失败!", TMsgColor.c_Red, TMsgType.t_Hint);
                        }
                    }
                    else
                    {
                        this.SendMsg(this, Grobal2.RM_OPENBOXS_FAIL, 0, 0, 0, 0, "");// 失败
                        this.SysMsg("您的宝箱和钥匙不对应,不能打开宝箱!", TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                }
                else
                {
                    this.SendMsg(this, Grobal2.RM_OPENBOXS_FAIL, 0, 0, 0, 0, "");// 失败
                    this.SysMsg("您的包裹已满,不能开启宝箱!", TMsgColor.c_Red, TMsgType.t_Hint);
                }
            }
        }

        // 判断宝箱和钥匙是否对应
        // 宝箱开启,随机取出9件物品
        public unsafe bool ClientOpenBoxs(int SBoxsID)
        {
            bool result;
            IList<IntPtr> vList1;
            IList<IntPtr> vList2;
            IList<IntPtr> vList3;
            IList<IntPtr> vList4;
            
            int T;
            TBoxsInfo BoxsInfo;
            TBoxsInfo BoxsInfo1;
            string sSendStr;
            result = false;
            sSendStr = "";
            byte[] data;
            if (M2Share.BoxsList == null)
            {
                return result;
            }
            if (m_boOpenBox)// 如果有宝箱正在操作,则退出,一次只能开一个宝箱
            {
                return result;
            }
            n_OpenBox = 0;
            n_IncUsesGameGold = 0;
            n_IncUsesGold = 0;
            n_BoxsItmeID = 0;// 初始化给人物物品的ID
            vList1 = new List<IntPtr>();
            vList2 = new List<IntPtr>();
            vList3 = new List<IntPtr>();
            vList4 = new List<IntPtr>();
            try
            {
                if (M2Share.BoxsList.Count > 0)
                {
                    //    for (T = 0; T < M2Share.BoxsList.Count; T++)
                    //    {
                    //        BoxsInfo1 = M2Share.BoxsList[T];
                    //        if (BoxsInfo1.SBoxsID != SBoxsID)
                    //        {
                    //            continue;
                    //        }
                    //        switch (BoxsInfo1.nItemType) // 如果不是Source对应的txt文件则跳过
                    //        {
                    //            case 0:
                    //                vList3.Add((IntPtr)BoxsInfo1); // 物品类型 0 的写入vList3
                    //                break;
                    //            case 1:
                    //                vList2.Add((IntPtr)BoxsInfo1);// 物品类型 1 的写入vList2
                    //                break;
                    //            case 2:
                    //                vList1.Add((IntPtr)BoxsInfo1); // 物品类型 2 的写入vList1
                    //                break;
                    //            case 3:
                    //                vList4.Add((IntPtr)BoxsInfo1);// 物品类型 3 的写入vList4
                    //                break;
                    //        }
                    //    }
                    //}
                    //// 要求,类型为2的要有最少1件,1的最少要有2件,0的最少要有4件,3的最少要2件,    分开取,使显示的位置不同 20080606
                    //if ((vList1.Count > 0) && (vList2.Count > 1) && (vList3.Count > 4) && (vList4.Count > 1))
                    //{
                    //    m_Boxs.Clear();
                    //    switch (HUtil32.Random(2))
                    //    {
                    //        case 0:
                    //            // 第一种显示方式
                    //            i = HUtil32.Random(vList3.Count);
                    //            // 物品类型为0的1条记录
                    //            BoxsInfo1 = ((TBoxsInfo*)(vList3[i]));
                    //            BoxsInfo = BoxsInfo1;
                    //            m_Boxs.Add((IntPtr)BoxsInfo1);// 保存随机取出的宝箱物品
                    //            data = new byte[sizeof(TBoxsInfo)];
                    //            fixed (byte* pb = data)
                    //            {
                    //                *(TBoxsInfo*)pb = *BoxsInfo;
                    //            }
                    //            sSendStr = sSendStr + EncryptUnit.EncodeBuffer(data, sizeof(TBoxsInfo)) + "/";
                    //            vList3.RemoveAt(i);// 抽取完后从临时列表中删除数据
                    //            i = HUtil32.Random(vList2.Count);// 物品类型为1
                    //            BoxsInfo1 = ((TBoxsInfo*)(vList2[i]));
                    //            BoxsInfo = BoxsInfo1;
                    //            m_Boxs.Add((IntPtr)BoxsInfo1);// 保存随机取出的宝箱物品
                    //            data = new byte[sizeof(TBoxsInfo)];
                    //            fixed (byte* pb = data)
                    //            {
                    //                *(TBoxsInfo*)pb = *BoxsInfo;
                    //            }
                    //            sSendStr = sSendStr + EncryptUnit.EncodeBuffer(data, sizeof(TBoxsInfo)) + "/";
                    //            vList2.RemoveAt(i);// 抽取完后从临时列表中删除数据
                    //            i = HUtil32.Random(vList3.Count);// 物品类型为0的1条记录
                    //            BoxsInfo1 = ((TBoxsInfo*)(vList3[i]));
                    //            BoxsInfo = BoxsInfo1;
                    //            m_Boxs.Add((IntPtr)BoxsInfo1);// 保存随机取出的宝箱物品
                    //            data = new byte[sizeof(TBoxsInfo)];
                    //            fixed (byte* pb = data)
                    //            {
                    //                *(TBoxsInfo*)pb = *BoxsInfo;
                    //            }
                    //            sSendStr = sSendStr + EncryptUnit.EncodeBuffer(data, sizeof(TBoxsInfo)) + "/";
                    //            vList3.RemoveAt(i);// 抽取完后从临时列表中删除数据
                    //            i = HUtil32.Random(vList4.Count);// 物品类型为3
                    //            BoxsInfo1 = ((TBoxsInfo*)(vList4[i]));
                    //            BoxsInfo = BoxsInfo1;
                    //            m_Boxs.Add((IntPtr)BoxsInfo1);// 保存随机取出的宝箱物品
                    //            data = new byte[sizeof(TBoxsInfo)];
                    //            fixed (byte* pb = data)
                    //            {
                    //                *(TBoxsInfo*)pb = *BoxsInfo;
                    //            }
                    //            sSendStr = sSendStr + EncryptUnit.EncodeBuffer(data, sizeof(TBoxsInfo)) + "/";
                    //            vList4.RemoveAt(i);// 抽取完后从临时列表中删除数据
                    //            i = HUtil32.Random(vList3.Count);// 物品类型为0的1条记录
                    //            BoxsInfo1 = ((TBoxsInfo*)(vList3[i]));
                    //            BoxsInfo = BoxsInfo1;
                    //            m_Boxs.Add((IntPtr)BoxsInfo1);// 保存随机取出的宝箱物品
                    //            data = new byte[sizeof(TBoxsInfo)];
                    //            fixed (byte* pb = data)
                    //            {
                    //                *(TBoxsInfo*)pb = *BoxsInfo;
                    //            }
                    //            sSendStr = sSendStr + EncryptUnit.EncodeBuffer(data, sizeof(TBoxsInfo)) + "/";
                    //            vList3.RemoveAt(i);// 抽取完后从临时列表中删除数据
                    //            i = HUtil32.Random(vList2.Count);// 物品类型为1
                    //            BoxsInfo1 = ((TBoxsInfo*)(vList2[i]));
                    //            BoxsInfo = BoxsInfo1;
                    //            m_Boxs.Add((IntPtr)BoxsInfo1);// 保存随机取出的宝箱物品
                    //            data = new byte[sizeof(TBoxsInfo)];
                    //            fixed (byte* pb = data)
                    //            {
                    //                *(TBoxsInfo*)pb = *BoxsInfo;
                    //            }
                    //            sSendStr = sSendStr + EncryptUnit.EncodeBuffer(data, sizeof(TBoxsInfo)) + "/";
                    //            vList2.RemoveAt(i);// 抽取完后从临时列表中删除数据
                    //            i = HUtil32.Random(vList3.Count);// 物品类型为0的1条记录
                    //            BoxsInfo1 = ((TBoxsInfo*)(vList3[i]));
                    //            BoxsInfo = BoxsInfo1;
                    //            m_Boxs.Add((IntPtr)BoxsInfo1);// 保存随机取出的宝箱物品
                    //            data = new byte[sizeof(TBoxsInfo)];
                    //            fixed (byte* pb = data)
                    //            {
                    //                *(TBoxsInfo*)pb = *BoxsInfo;
                    //            }
                    //            sSendStr = sSendStr + EncryptUnit.EncodeBuffer(data, sizeof(TBoxsInfo)) + "/";
                    //            vList3.RemoveAt(i);// 抽取完后从临时列表中删除数据
                    //            i = HUtil32.Random(vList4.Count);// 物品类型为3
                    //            BoxsInfo1 = ((TBoxsInfo*)(vList4[i]));
                    //            BoxsInfo = BoxsInfo1;
                    //            m_Boxs.Add((IntPtr)BoxsInfo1);// 保存随机取出的宝箱物品
                    //            data = new byte[sizeof(TBoxsInfo)];
                    //            fixed (byte* pb = data)
                    //            {
                    //                *(TBoxsInfo*)pb = *BoxsInfo;
                    //            }
                    //            sSendStr = sSendStr + EncryptUnit.EncodeBuffer(data, sizeof(TBoxsInfo)) + "/";
                    //            vList4.RemoveAt(i);// 抽取完后从临时列表中删除数据
                    //            break;
                    //        case 1:// 第二种显示方式
                    //            i = HUtil32.Random(vList2.Count);// 物品类型为1
                    //            BoxsInfo1 = ((TBoxsInfo*)(vList2[i]));
                    //            BoxsInfo = BoxsInfo1;
                    //            m_Boxs.Add((IntPtr)BoxsInfo1);// 保存随机取出的宝箱物品
                    //            data = new byte[sizeof(TBoxsInfo)];
                    //            fixed (byte* pb = data)
                    //            {
                    //                *(TBoxsInfo*)pb = *BoxsInfo;
                    //            }
                    //            sSendStr = sSendStr + EncryptUnit.EncodeBuffer(data, sizeof(TBoxsInfo)) + "/";
                    //            vList2.RemoveAt(i);// 抽取完后从临时列表中删除数据
                    //            i = HUtil32.Random(vList3.Count);// 物品类型为0的1条记录
                    //            BoxsInfo1 = ((TBoxsInfo*)(vList3[i]));
                    //            BoxsInfo = BoxsInfo1;
                    //            m_Boxs.Add((IntPtr)BoxsInfo1);// 保存随机取出的宝箱物品
                    //            data = new byte[sizeof(TBoxsInfo)];
                    //            fixed (byte* pb = data)
                    //            {
                    //                *(TBoxsInfo*)pb = *BoxsInfo;
                    //            }
                    //            sSendStr = sSendStr + EncryptUnit.EncodeBuffer(data, sizeof(TBoxsInfo)) + "/";
                    //            vList3.RemoveAt(i);// 抽取完后从临时列表中删除数据
                    //            i = HUtil32.Random(vList4.Count);// 物品类型为3
                    //            BoxsInfo1 = ((TBoxsInfo*)(vList4[i]));
                    //            BoxsInfo = BoxsInfo1;
                    //            m_Boxs.Add((IntPtr)BoxsInfo1);// 保存随机取出的宝箱物品
                    //            data = new byte[sizeof(TBoxsInfo)];
                    //            fixed (byte* pb = data)
                    //            {
                    //                *(TBoxsInfo*)pb = *BoxsInfo;
                    //            }
                    //            sSendStr = sSendStr + EncryptUnit.EncodeBuffer(data, sizeof(TBoxsInfo)) + "/";
                    //            vList4.RemoveAt(i);// 抽取完后从临时列表中删除数据
                    //            i = HUtil32.Random(vList3.Count);// 物品类型为0的1条记录
                    //            BoxsInfo1 = ((TBoxsInfo*)(vList3[i]));
                    //            BoxsInfo = BoxsInfo1;
                    //            m_Boxs.Add((IntPtr)BoxsInfo1);// 保存随机取出的宝箱物品
                    //            data = new byte[sizeof(TBoxsInfo)];
                    //            fixed (byte* pb = data)
                    //            {
                    //                *(TBoxsInfo*)pb = *BoxsInfo;
                    //            }
                    //            sSendStr = sSendStr + EncryptUnit.EncodeBuffer(data, sizeof(TBoxsInfo)) + "/";
                    //            vList3.RemoveAt(i);// 抽取完后从临时列表中删除数据
                    //            i = HUtil32.Random(vList2.Count);// 物品类型为1
                    //            BoxsInfo1 = ((TBoxsInfo*)(vList2[i]));
                    //            BoxsInfo = BoxsInfo1;
                    //            m_Boxs.Add((IntPtr)BoxsInfo1);// 保存随机取出的宝箱物品
                    //            data = new byte[sizeof(TBoxsInfo)];
                    //            fixed (byte* pb = data)
                    //            {
                    //                *(TBoxsInfo*)pb = *BoxsInfo;
                    //            }
                    //            sSendStr = sSendStr + EncryptUnit.EncodeBuffer(data, sizeof(TBoxsInfo)) + "/";
                    //            vList2.RemoveAt(i);// 抽取完后从临时列表中删除数据
                    //            i = HUtil32.Random(vList3.Count);// 物品类型为0的1条记录
                    //            BoxsInfo1 = ((TBoxsInfo*)(vList3[i]));
                    //            BoxsInfo = BoxsInfo1;
                    //            m_Boxs.Add((IntPtr)BoxsInfo1);// 保存随机取出的宝箱物品
                    //            data = new byte[sizeof(TBoxsInfo)];
                    //            fixed (byte* pb = data)
                    //            {
                    //                *(TBoxsInfo*)pb = *BoxsInfo;
                    //            }
                    //            sSendStr = sSendStr + EncryptUnit.EncodeBuffer(data, sizeof(TBoxsInfo)) + "/";
                    //            vList3.RemoveAt(i);// 抽取完后从临时列表中删除数据
                    //            i = HUtil32.Random(vList4.Count);// 物品类型为3
                    //            BoxsInfo1 = ((TBoxsInfo*)(vList4[i]));
                    //            BoxsInfo = BoxsInfo1;
                    //            m_Boxs.Add((IntPtr)BoxsInfo1);// 保存随机取出的宝箱物品
                    //            data = new byte[sizeof(TBoxsInfo)];
                    //            fixed (byte* pb = data)
                    //            {
                    //                *(TBoxsInfo*)pb = *BoxsInfo;
                    //            }
                    //            sSendStr = sSendStr + EncryptUnit.EncodeBuffer(data, sizeof(TBoxsInfo)) + "/";
                    //            vList4.RemoveAt(i);// 抽取完后从临时列表中删除数据
                    //            i = HUtil32.Random(vList3.Count);// 物品类型为0的1条记录
                    //            BoxsInfo1 = ((TBoxsInfo*)(vList3[i]));
                    //            BoxsInfo = BoxsInfo1;
                    //            m_Boxs.Add((IntPtr)BoxsInfo1);// 保存随机取出的宝箱物品
                    //            data = new byte[sizeof(TBoxsInfo)];
                    //            fixed (byte* pb = data)
                    //            {
                    //                *(TBoxsInfo*)pb = *BoxsInfo;
                    //            }
                    //            sSendStr = sSendStr + EncryptUnit.EncodeBuffer(data, sizeof(TBoxsInfo)) + "/";
                    //            vList3.RemoveAt(i); // 抽取完后从临时列表中删除数据
                    //            break;
                    //    }
                    //    i = HUtil32.Random(vList1.Count);// 取出一条物品类型为2的数据
                    //    BoxsInfo1 = ((TBoxsInfo*)(vList1[i]));
                    //    BoxsInfo = BoxsInfo1;
                    //    n_BoxsItmeID = BoxsInfo->StdItem.MakeIndex;// 得到中间物品的ID
                    //    data = new byte[sizeof(TBoxsInfo)];
                    //    fixed (byte* pb = data)
                    //    {
                    //        *(TBoxsInfo*)pb = *BoxsInfo;
                    //    }
                    //    sSendStr = sSendStr + EncryptUnit.EncodeBuffer(data, sizeof(TBoxsInfo)) + "/";
                    //    m_Boxs.Add((IntPtr)BoxsInfo1);// 保存随机取出的宝箱物品
                }
            }
            finally
            {
                Dispose(vList1);
                Dispose(vList2);
                Dispose(vList3);
            }
            if (sSendStr != "")
            {
                this.SendMsg(this, Grobal2.RM_OPENBOXS, 0, 0, 0, 0, sSendStr);
                m_boOpenBox = true;// 宝箱正在打开中
                result = true;
            }
            return result;
        }

        public unsafe int ClientGetBoxs_GetItemID(List<TBoxsInfo> BoxS, int ItemType)
        {
            int result;
            TBoxsInfo pBoxsInfo;
            IList<TBoxsInfo> sTemp;
            result = 0;
            sTemp = new List<TBoxsInfo>();
            int T;
            if (BoxS.Count > 0)
            {
                for (int i = 0; i < BoxS.Count; i++)
                {
                    pBoxsInfo = BoxS[i];
                    if (pBoxsInfo.nItemType != ItemType)
                    {
                        continue;
                    }
                    sTemp.Add(pBoxsInfo);
                }
            }
            if (sTemp.Count > 0)
            {
                for (int i = 0; i < sTemp.Count; i++)
                {
                    T = HUtil32.Random(sTemp.Count);
                    pBoxsInfo = sTemp[T];
                    result = pBoxsInfo.StdItem.MakeIndex;
                    if (result != 0)
                    {
                        break;
                    }
                }
            }
            Dispose(sTemp);
            return result;
        }

        // 宝箱类型,即Source
        // 打开宝箱
        // 转动宝箱,随机给客户端一件物品,并减少一定的金币或元宝
        public void ClientGetBoxs()
        {
            TBoxsInfo BoxsInfo1;
            int UsesGold;
            int UsesGameGold;
            bool OpenBox_OK;// 打开宝箱是否成功
            OpenBox_OK = false;
            UsesGold = 0;
            UsesGameGold = 0;
            try
            {
                if ((m_Boxs == null) || (m_Boxs.Count == 0))
                {
                    return;
                }
                n_BoxsItmeID = 0;
                n_OpenBox++;// 开宝箱记数
                var i = HUtil32.Random(m_Boxs.Count);
                BoxsInfo1 = m_Boxs[i];
                if (n_OpenBox == 1) // 免费转动一次
                {
                    UsesGold = BoxsInfo1.nGold;// 转动所需的金币数
                    UsesGameGold = (int)BoxsInfo1.nGameGold;// 转动所需的元宝数
                    n_BoxsItmeID = ClientGetBoxs_GetItemID(m_Boxs, 0);
                    OpenBox_OK = true;
                }
                else
                {
                    // 收费转动
                    if (!(n_OpenBox > BoxsInfo1.nUses))// 没有超过最大使用次数
                    {
                        UsesGold = (BoxsInfo1.nGold + BoxsInfo1.nIncGold * (n_OpenBox - 2));// 转动所需的金币数   [起始值+累计值*(次数-2)]
                        UsesGameGold = Convert.ToInt32(BoxsInfo1.nGameGold + BoxsInfo1.nIncGameGold * (n_OpenBox - 2));// 转动所需的元宝数
                        if ((this.m_nGold >= UsesGold) && (m_nGameGold >= UsesGameGold))
                        {
                            this.m_nGold -= UsesGold;
                            m_nGameGold -= UsesGameGold;
                            n_IncUsesGold += UsesGold;
                            n_IncUsesGameGold += UsesGameGold;
                            this.GoldChanged();// 更新客户端金币
                            this.GameGoldChanged();// 更新客户端元宝
                            OpenBox_OK = true;// 物消费总值大于或等于有效金币数和元宝数,则给玩家 不可得的物品
                            if ((n_IncUsesGold >= BoxsInfo1.nEffectiveGold) && (n_IncUsesGameGold >= BoxsInfo1.nEffectiveGameGold))
                            {
                                n_BoxsItmeID = ClientGetBoxs_GetItemID(m_Boxs, 1);
                            }
                            else
                            {
                                n_BoxsItmeID = ClientGetBoxs_GetItemID(m_Boxs, 0);
                            }
                        }
                        else
                        {
                            // 人物的金币或元宝数不足
                            this.SysMsg("您的金币或元宝数不足,不能再转动宝箱!", TMsgColor.c_Red, TMsgType.t_Hint);
                        }
                    }
                    else
                    {
                        // 超过最大使用次数
                        this.SysMsg("宝箱已无法再使用!", TMsgColor.c_Red, TMsgType.t_Hint);
                    }
                }
                if (OpenBox_OK) // 发消息给客户端
                {
                    if (n_OpenBox == 1)
                    {
                        this.SendMsg(this, Grobal2.RM_MOVEBOXS, 0, n_BoxsItmeID, UsesGold, UsesGameGold, "");
                    }
                    else
                    {
                        this.SendMsg(this, Grobal2.RM_MOVEBOXS, 0, n_BoxsItmeID, (BoxsInfo1.nGold + BoxsInfo1.nIncGold * (n_OpenBox - 1)),
                            (int)(BoxsInfo1.nGameGold + BoxsInfo1.nIncGameGold * (n_OpenBox - 1)), "");
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TPlayObject::ClientGetBoxs");
            }
        }

        /// <summary>
        /// 宝箱给玩家物品
        /// </summary>
        public unsafe void ClientGetBoxsItme()
        {
            int ItemNum;
            TUserItem UserItem = null;
            TStdItem StdItem;
            TBoxsInfo BoxsInfo = null;
            string ItemName = string.Empty;
            string sCheckItemName;
            string szString;
            if (!m_boOpenBox)
            {
                return;
            }
            try
            {
                m_boOpenBox = false;
                ItemNum = 0;
                if (n_BoxsItmeID != 0)
                {
                    if (M2Share.BoxsList.Count > 0)
                    {
                        for (int i = 0; i < M2Share.BoxsList.Count; i++)
                        {
                            BoxsInfo = M2Share.BoxsList[i];
                            if (BoxsInfo.StdItem.MakeIndex == n_BoxsItmeID)
                            {
                                ItemName = BoxsInfo.StdItem.s.Name;// 物品名称
                                ItemNum = BoxsInfo.nItemNum;// 物品数量
                            }
                            if (ItemName != "")
                            {
                                break;
                            }
                        }
                    }
                    StdItem = M2Share.UserEngine.GetStdItem(ItemName);
                    if ((StdItem != null))
                    {
                        if (ItemNum <= 0)
                        {
                            ItemNum = 1;
                        }
                        for (int i = 0; i < ItemNum; i++)
                        {
                            // 支持物品的多数量获取
                            UserItem = new TUserItem();//new TUserItem();
                            if (M2Share.UserEngine.CopyToUserItemFromName(StdItem.Name, UserItem))
                            {
                                UserItem.Dura = (ushort)BoxsInfo.StdItem.Dura;
                                if (IsEnoughBag() && this.IsAddWeightAvailable(StdItem.Weight))  // 包裹有位置则放到包裹里,没有则扔出物品
                                {
                                    this.m_ItemList.Add(UserItem);
                                    if (StdItem.NeedIdentify == 1)
                                    {
                                        M2Share.AddGameDataLog("40" + "\09" + this.m_sMapName + "\09" + (this.m_nCurrX).ToString() + "\09" + (this.m_nCurrY).ToString() + "\09" + this.m_sCharName + "\09"
                                            + StdItem.Name + "\09" + (UserItem.MakeIndex).ToString() + "\09" + "(" + (HUtil32.LoWord(StdItem.DC)).ToString() + "/" + (HUtil32.HiWord(StdItem.DC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MC)).ToString()
                                            + "/" + (HUtil32.HiWord(StdItem.MC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.SC)).ToString() + "/" + (HUtil32.HiWord(StdItem.SC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.AC)).ToString() +
                                            "/" + (HUtil32.HiWord(StdItem.AC)).ToString() + ")" + "(" + (HUtil32.LoWord(StdItem.MAC)).ToString() + "/" + (HUtil32.HiWord(StdItem.MAC)).ToString() + ")" + (UserItem.btValue[0]).ToString() + "/"
                                            + (UserItem.btValue[1]).ToString() + "/" + (UserItem.btValue[2]).ToString() + "/" + (UserItem.btValue[3]).ToString() + "/" + (UserItem.btValue[4]).ToString() + "/"
                                            + (UserItem.btValue[5]).ToString() + "/" + (UserItem.btValue[6]).ToString() + "/" + (UserItem.btValue[7]).ToString() + "/" + (UserItem.btValue[8]).ToString() + "/"
                                            + (UserItem.btValue[14]).ToString() + "\09" + "0");
                                    }
                                    if (this.m_btRaceServer == Grobal2.RC_PLAYOBJECT)
                                    {
                                        SendAddItem(UserItem);
                                        SendUpdateItem(UserItem);// 更新物品
                                        sCheckItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                                        this.PlugOfCheckCanItem(5, sCheckItemName, false, 0, 0);// 禁止物品规则(管理插件功能) 20080729
                                    }
                                }
                                else
                                {
                                    // 扔出物品
                                    this.DropItemDown(UserItem, 3, false, false, this, this);
                                }
                            }
                            else
                            {
                               UserItem=null;
                                break;
                            }
                        }
                        // UserEngine.SendBroadCastMsgExt('系统：恭喜玩家 '+m_sCharName+' 开启宝箱获得'+inttostr(ItemNum)+'件【'+HUtil32.SBytePtrToString(StdItem.Name,0,StdItem.NameLen)+'】', t_Say);//向每个人物发送消息
                    }
                    else
                    {
                        // 不是数据库里的物品
                        if ((ItemName.Trim()).ToLower().CompareTo(("经验").ToLower()) == 0)
                        {
                            GetExpToItem(ItemNum);// 取得的经验,累积到聚灵珠
                            if (m_MyHero != null)
                            {
                                //((THeroObject)(m_MyHero)).GetExp(Math.Abs(HUtil32.Round((M2Share.g_Config.nHeroNoKillMonExpRate / 100) * ItemNum)));
                                ItemNum = Math.Abs((int)HUtil32.Round((double)((100 - M2Share.g_Config.nHeroNoKillMonExpRate) / 100) * ItemNum, 1));
                            }
                            if (this.m_Abil.Exp >= (uint)ItemNum)
                            {
                                if ((uint.MaxValue - this.m_Abil.Exp) < (uint)ItemNum)
                                {
                                    ItemNum = Convert.ToInt32(uint.MaxValue - this.m_Abil.Exp);
                                }
                            }
                            else
                            {
                                if ((uint.MaxValue - (uint)ItemNum) < this.m_Abil.Exp)
                                {
                                    ItemNum = Convert.ToInt32(uint.MaxValue - (uint)ItemNum);
                                }
                            }
                            m_GetExp = ItemNum;// 人物取得的经验,$GetExp变量使用
                            if (M2Share.g_FunctionNPC != null) // 取经验触发
                            {
                                M2Share.g_FunctionNPC.GotoLable(this, "@GetExp", false);
                            }
                            this.m_Abil.Exp += ItemNum;
                            this.SendMsg(this, Grobal2.RM_WINEXP, 0, ItemNum, 0, 0, "");
                        }
                        else if ((ItemName.Trim()).ToLower().CompareTo(("声望").ToLower()) == 0)
                        {
                            m_btCreditPoint += (UInt16)ItemNum;
                            szString = GameMsgDef.g_sBoxsItemHintMsg.Replace("%name", this.m_sCharName);
                            szString = szString.Replace("%s", "声望  " + (ItemNum).ToString());
                            M2Share.UserEngine.SendBroadCastMsgExt(szString, TMsgType.t_Say);// 向每个人物发送消息
                        }
                        else if ((ItemName.Trim()).ToLower().CompareTo((M2Share.g_Config.sGameDiaMond).ToLower()) == 0)
                        {
                            m_nGAMEDIAMOND += ItemNum;
                            this.GameGoldChanged();// 更新金刚石数量
                            szString = GameMsgDef.g_sBoxsItemHintMsg.Replace("%name", this.m_sCharName);
                            szString = szString.Replace("%s", M2Share.g_Config.sGameDiaMond + "  " + (ItemNum).ToString());
                            M2Share.UserEngine.SendBroadCastMsgExt(szString, TMsgType.t_Say);// 向每个人物发送消息
                        }
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TPlayObject::ClientGetBoxsItme");
            }
        }

        // --------------------淬炼系统--------------
        // 客户端增加物品到淬炼框中
        public unsafe bool ClientAddRefineItem(string sItemIdx)
        {
            bool result;
            
            TUserItem UserItem;
            int nItemIdx;
            int nItemIdx1;
            int nItemIdx2;
            string Str = string.Empty;
            string Str1 = string.Empty;
            result = false;
            nItemIdx = 0;
            nItemIdx1 = 0;
            nItemIdx2 = 0;
            if (sItemIdx != "")
            {
                sItemIdx = HUtil32.GetValidStr3(sItemIdx, ref Str, new string[] { "/", "\09" });
                sItemIdx = HUtil32.GetValidStr3(sItemIdx, ref Str1, new string[] { "/", "\09" });
                nItemIdx = HUtil32.Str_ToInt(Str, 0);
                nItemIdx1 = HUtil32.Str_ToInt(Str1, 0);
                nItemIdx2 = HUtil32.Str_ToInt(sItemIdx, 0);
            }
            for (var i = this.m_ItemList.Count - 1; i >= 0; i--)
            {
                if (this.m_ItemList.Count <= 0)
                {
                    break;
                }
                UserItem = (TUserItem)this.m_ItemList[i];
                if (UserItem == null)
                {
                    continue;
                }
                if ((UserItem.MakeIndex == nItemIdx) || (UserItem.MakeIndex == nItemIdx1) || (UserItem.MakeIndex == nItemIdx2))
                {
                    if ((m_RefineItemList.Count < 4))
                    {
                        m_RefineItemList.Add(UserItem);
                        this.m_ItemList.RemoveAt(i);
                        if (m_RefineItemList.Count == 3)
                        {
                            result = true;
                            break;
                        }
                    }
                }
            }
            return result;
        }


        // 修补火云石
        // ---------------------------------------------------
        // ------------------------------------------------------------------------------
        // 取回英雄
        public unsafe void ClientGETHERO(string sHeroName, byte nHeroTpye)
        {
            if (sHeroName != "")
            {
                m_sHeroCharName = sHeroName;
                n_myHeroTpye = nHeroTpye;
                switch (n_myHeroTpye)// 英雄的类型
                {
                    case 0:
                        m_boHasHero = true;
                        break;
                    case 1:
                        m_boHasHeroTwo = true;
                        break;
                }
                if (M2Share.g_FunctionNPC != null)
                {
                    M2Share.g_FunctionNPC.GotoLable(this, "@GetHeroOk", false);
                }
            }
            else
            {
                if (M2Share.g_FunctionNPC != null)
                {
                    M2Share.g_FunctionNPC.GotoLable(this, "@GetHeroBak", false);
                }
            }
        }

        // 请酒
        public unsafe void ClientPlayDrinkItem(int NPC, int nItemIdx, string sMsg)
        {
            TMerchant Merchant;
            
            TUserItem UserItem;
            bool bo19;
            TStdItem StdItem;
            string sUserItemName;
            bo19 = false;
            Merchant = (TMerchant)M2Share.UserEngine.FindMerchant(NPC);
            if ((Merchant != null) && (Merchant.m_boPlayDrink))
            {
                // 请酒斗酒NPC
                // 折分物品名称(信件物品的名称后面加了使用次数)
                if (sMsg.IndexOf(" ") >= 0)
                {
                    HUtil32.GetValidStr3(sMsg, ref sMsg, new string[] { " " });
                }
                for (var i = this.m_ItemList.Count - 1; i >= 0; i--)
                {
                    if (this.m_ItemList.Count <= 0)
                    {
                        break;
                    }
                    UserItem = this.m_ItemList[i];
                    if (UserItem.MakeIndex == nItemIdx)
                    {
                        // 取自定义物品名称
                        sUserItemName = "";
                        if (UserItem.btValue[13] == 1)
                        {
                            sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                        }
                        if (sUserItemName == "")
                        {
                            sUserItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                        }
                        if ((sUserItemName).ToLower().CompareTo((sMsg).ToLower()) == 0)
                        {
                            StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                            if ((StdItem.StdMode == 60) && (StdItem.Shape == 0)) // 是烧酒
                            {
                                this.m_ItemList.RemoveAt(i);// 删除物品
                                bo19 = true;
                            }
                        }
                        break;
                    }
                }
            }
            if (bo19)
            {
                SendDefMessage(Grobal2.SM_USERPLAYDRINK_OK, 0, 0, 0, 0, "");
                if (Merchant != null)
                {
                    Merchant.GotoLable(this, "~PlayDrink_Game", false);
                }
            }
            else
            {
                SendDefMessage(Grobal2.SM_USERPLAYDRINK_FAIL, 0, 0, 0, 0, "");
            }
        }

        // 请酒信息跳转
        public unsafe void ClientPlayDrinkLable(int nParam1, string sMsg)
        {
            TNormNpc NPC;
            string sLabel = string.Empty;
            if (this.m_boDeath || this.m_boGhost)
            {
                return;
            }
            NPC = M2Share.UserEngine.FindMerchant(nParam1);
            if (NPC == null)
            {
                NPC = M2Share.UserEngine.FindMerchant(nParam1);
            }
            if (NPC == null)
            {
                return;
            }
            if ((sMsg != "") && (sMsg[0] == '@'))
            {
                HUtil32.GetValidStr3(sMsg, ref sLabel, new string[] { "\r" });
                NPC.GotoLable(this, sLabel, false);
            }
        }

        // 请酒信息跳转
        // 比较NPC与玩家出码数,并判断输赢
        // 码值:0-石 1-剪刀 2-布  nCode 0-赢  1-输  2-平
        public unsafe void ClientPlayDrinkToDrink(int nParam1, byte nPlayNum)
        {
            byte nNpcNum;
            byte nCode;
            TNormNpc NPC;
            nCode = 3;// 猜码结果
            nNpcNum = (byte)HUtil32.Random(3);
            switch (nPlayNum)
            {
                case 0:
                    // 随机取NPC出码值
                    switch (nNpcNum)
                    {
                        case 0: // 平
                            nCode = 2;
                            break;
                        case 1: // 输
                            nCode = 0;
                            break;
                        case 2: // 赢
                            nCode = 1;
                            break;
                    }
                    break;
                case 1:
                    switch (nNpcNum)
                    {
                        case 0:// 输
                            nCode = 1;
                            break;
                        case 1: // 平
                            nCode = 2;
                            break;
                        case 2:// 赢
                            nCode = 0;
                            break;
                    }
                    break;
                case 2:
                    switch (nNpcNum)
                    {
                        case 0: // 赢
                            nCode = 0;
                            break;
                        case 1: // 输
                            nCode = 1;
                            break;
                        case 2: // 平
                            nCode = 2;
                            break;
                    }
                    break;
            }
            if ((nCode < 3)) // 有了结果,发消息给客户端
            {
                NPC = M2Share.UserEngine.FindMerchant(nParam1);
                if (NPC == null)
                {
                    NPC = M2Share.UserEngine.FindMerchant(nParam1);
                }
                switch (nCode)
                {
                    case 0:// 玩家赢
                        NPC.GotoLable(this, "~PlayDrink_PlayWil", false);
                        break;
                    case 1: // NPC赢
                        NPC.GotoLable(this, "~PlayDrink_NpcWil", false);
                        break;
                }
                this.SendMsg(this, Grobal2.RM_PlayDrinkToDrink, 0, nPlayNum, nNpcNum, nCode, "");
            }
        }

        /// <summary>
        /// 比较NPC与玩家出码数,并判断输赢
        /// 喝酒并增加醉酒值
        /// 参数:nPlayNum--谁喝酒(0-玩家喝 1-NPC喝) nCode--谁赢(0-NPC 1-玩家)
        /// 如果NPC胜,则随机选择谁喝酒,玩家胜,则以玩家的选择来决定
        /// </summary>
        /// <param name="nParam1"></param>
        /// <param name="nPlayNum">谁喝酒(0-玩家喝 1-NPC喝)</param>
        /// <param name="nCode">谁赢(0-NPC 1-玩家)</param>
        public unsafe void ClientDrinkUpdateValue(int nParam1, byte nPlayNum, byte nCode)
        {
            TNormNpc NPC;
            bool boDrinkLoss;
            if (n_DrinkCount < 7)
            {
                boDrinkLoss = true;
                NPC = M2Share.UserEngine.FindMerchant(nParam1);
                if (NPC == null)
                {
                    NPC = M2Share.UserEngine.FindMerchant(nParam1);
                }
                n_DrinkCount++;// 累积喝酒次数,即喝了几瓶酒
                switch (nCode)
                {
                    case 0:
                        switch (HUtil32.Random(2))// NPC胜
                        {
                            case 0:// 玩家喝
                                n_DrinkValue[1] = Convert.ToByte(n_DrinkValue[1] + HUtil32.Random(25) + 8);
                                if (n_DrinkValue[1] > 100)
                                {
                                    n_DrinkValue[1] = 100;
                                }
                                nPlayNum = 0;
                                NPC.GotoLable(this, "~PlayDrink_NpcToSelf", false);
                                break;
                            case 1:// NPC喝
                                n_DrinkValue[0] = Convert.ToByte(n_DrinkValue[0] + HUtil32.Random(25) + 8);
                                if (n_DrinkValue[0] > 100)
                                {
                                    n_DrinkValue[0] = 100;
                                }
                                nPlayNum = 1;
                                NPC.GotoLable(this, "~PlayDrink_NpcToNpc", false);
                                break;
                        }
                        break;
                    case 1:
                        switch (nPlayNum)// 玩家胜
                        {
                            case 0:// 玩家喝
                                n_DrinkValue[1] = Convert.ToByte(n_DrinkValue[1] + HUtil32.Random(30) + 10);
                                if (n_DrinkValue[1] > 100)
                                {
                                    n_DrinkValue[1] = 100;
                                }
                                NPC.GotoLable(this, "~PlayDrink_SelfToSelf", false);
                                break;
                            case 1:// NPC喝
                                n_DrinkValue[0] = Convert.ToByte(n_DrinkValue[0] + HUtil32.Random(30) + 10);
                                if (n_DrinkValue[0] > 100)
                                {
                                    n_DrinkValue[0] = 100;
                                }
                                NPC.GotoLable(this, "~PlayDrink_SelfToNpc", false);
                                break;
                        }
                        break;
                }
                // case nCode of
                if (n_DrinkValue[0] >= 92)
                {
                    // NPC喝醉,斗酒失败
                    NPC.GotoLable(this, "~PlayDrink_Npc_Drunk", false);
                    boDrinkLoss = false;
                }
                else if (n_DrinkValue[1] >= 92)
                {
                    // 玩家喝醉
                    NPC.GotoLable(this, "~PlayDrink_Self_Drunk", false);
                    boDrinkLoss = false;
                }
                else if (n_DrinkCount == 6)
                {
                    // 喝完酒,判断结果
                    if (n_DrinkValue[0] > n_DrinkValue[1])
                    {
                        // 玩家斗酒胜
                        NPC.GotoLable(this, "~PlayDrink_Npc_Loss", false);
                    }
                    else
                    {
                        NPC.GotoLable(this, "~PlayDrink_Self_Loss", false);
                    }
                    boDrinkLoss = false;
                }
                if (boDrinkLoss)
                {
                    // 参数0-可以继续喝 1-斗酒结束
                    this.SendMsg(this, Grobal2.RM_DrinkUpdateValue, 0, nPlayNum, n_DrinkValue[0], n_DrinkValue[1], "");
                }
                else
                {
                    this.SendMsg(this, Grobal2.RM_DrinkUpdateValue, 1, nPlayNum, n_DrinkValue[0], n_DrinkValue[1], "");
                }
            }
        }

        // 喝酒并增加醉酒值 
        // 请酒
        // 判断放上的两物品是不是烧酒,如果是则删除物品,触发脚本段
        public unsafe void ClientPlayDrink(string sMsg)
        {
            TMerchant Merchant;
            
            TUserItem UserItem;
            bool bo19;
            bool bo20;
            TStdItem StdItem;
            int nItemIdx;
            int nItemIdx1;
            int NPCID;
            string Str = string.Empty;
            string Str1 = string.Empty;
            NPCID = 0;
            nItemIdx = 0;
            nItemIdx1 = 0;
            bo19 = false;
            bo20 = false;
            if (sMsg != "")
            {
                sMsg = HUtil32.GetValidStr3(sMsg, ref Str, new string[] { "/", "\09" });
                sMsg = HUtil32.GetValidStr3(sMsg, ref Str1, new string[] { "/", "\09" });
                NPCID = HUtil32.Str_ToInt(Str, 0);
                nItemIdx = HUtil32.Str_ToInt(Str1, 0);
                nItemIdx1 = HUtil32.Str_ToInt(sMsg, 0);
            }
            if ((NPCID != 0) && (nItemIdx != 0) && (nItemIdx1 != 0))
            {
                Merchant = (TMerchant)M2Share.UserEngine.FindMerchant(NPCID);
                if ((Merchant != null) && (Merchant.m_boPlayDrink)) // 请酒NPC
                {
                    for (var i = this.m_ItemList.Count - 1; i >= 0; i--)
                    {
                        if (this.m_ItemList.Count <= 0)
                        {
                            break;
                        }
                        UserItem = this.m_ItemList[i];
                        if (UserItem.MakeIndex == nItemIdx)
                        {
                            StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                            if ((StdItem.StdMode == 60) && (StdItem.Shape == 0))
                            {
                                bo19 = true; // 是烧酒
                            }
                        }
                        else if (UserItem.MakeIndex == nItemIdx1)
                        {
                            StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                            if ((StdItem.StdMode == 60) && (StdItem.Shape == 0))
                            {
                                bo20 = true;// 是烧酒
                            }
                        }
                        if (bo19 && bo20)
                        {
                            break;
                        }
                    }
                }
                if (bo19 && bo20)
                {
                    for (var i = this.m_ItemList.Count - 1; i >= 0; i--)
                    {
                        // 删除物品
                        if (this.m_ItemList.Count <= 0)
                        {
                            break;
                        }
                        UserItem = this.m_ItemList[i];
                        if ((UserItem.MakeIndex == nItemIdx) || (UserItem.MakeIndex == nItemIdx1))
                        {
                            this.m_ItemList.RemoveAt(i);
                        }
                    }
                    SendDefMessage(Grobal2.SM_USERPLAYDRINKITEM_OK, 0, 0, 0, 0, "");
                    m_boPlayDrink = true;// 是否请过酒 T-请过酒
                    if (Merchant != null)
                    {
                        Merchant.GotoLable(this, "~PlayDrink_Ok", false);
                    }
                }
                else
                {
                    SendDefMessage(Grobal2.SM_USERPLAYDRINKITEM_FAIL, 0, 0, 0, 0, "");
                }
            }
        }

        /// <summary>
        /// 取天地结晶当前等级的经验，内功上限值 
        /// </summary>
        /// <param name="nLevel"></param>
        /// <param name="nMaxExp">当前经验上限</param>
        /// <param name="nMaxNGExp"></param>
        /// <returns>内功经验上限</returns>
        private bool GetExpCrystal(byte nLevel, ref int nMaxExp, ref int nMaxNGExp)
        {
            bool result = true;
            if (nLevel < 5)
            {
                nMaxExp = 0;
                nMaxNGExp = 0;
                nMaxExp = M2Share.g_Config.dwNGExpCrystalNeedExps[nLevel];
                nMaxNGExp = M2Share.g_Config.dwExpCrystalNeedExps[nLevel];
            }
            return result;
        }

        /// <summary>
        /// 客户端点击天地结晶，返回经验等信息
        /// </summary>
        private void ClientGetExpCrystalData()
        {
            if (m_boShowExpCrystal && m_boGetExpCrystalExp) // 天地结晶图标为显示，并且可以提取经验时
            {
                if ((m_nGetCrystalExp > 0) && (m_nGetCrystalNGExp > 0) && (m_CrystalLevel < 6) && (m_CrystalLevel > 0))
                {
                    if (M2Share.g_FunctionNPC != null)
                    {
                        M2Share.g_FunctionNPC.GotoLable(this, "@GetCrystalData", false);// 返回经验等信息触发
                    }
                }
            }
        }

        /// <summary>
        /// 客户端提取天地结晶经验
        /// </summary>
        public void ClientGetExpTCrystal()
        {
            if (m_boShowExpCrystal && m_boGetExpCrystalExp)// 天地结晶图标为显示，并且可以提取经验时
            {
                if ((m_nGetCrystalExp > 0) && (m_nGetCrystalNGExp > 0) && (m_CrystalLevel < 6) && (m_CrystalLevel > 0)) // 人物获得经验
                {
                    GetNGExp(m_nGetCrystalNGExp, 3);// 取天地结晶内功经验
                    GetExp(m_nGetCrystalExp, false, 3);// 取天地结晶经验
                    m_CrystalNGExp = m_CrystalNGExp - m_nGetCrystalNGExp; // 取得经验后的处理
                    m_CrystalExp = m_CrystalExp - m_nGetCrystalExp;
                    m_CrystalLevel = 1;
                    m_nGetCrystalNGExp = 0;
                    m_nGetCrystalExp = 0;
                    m_boGetExpCrystalExp = false;
                    GetExpCrystal(m_CrystalLevel, ref m_CrystalMaxExp, ref m_CrystalNGMaxExp);// 取天地结晶当前等级经验上限
                    SendDefMessage(Grobal2.SM_SENDCRYSTALLEVEL, m_CrystalLevel, 0, 0, 0, "");
                    SendDefMessage(Grobal2.SM_SENDCRYSTALNGEXP, 0, 0, 0, 0, (m_CrystalNGExp).ToString() + "/"
                        + (m_CrystalMaxExp).ToString() + "/" + (m_CrystalNGMaxExp).ToString());// 发送天地结晶内功经验
                    SendDefMessage(Grobal2.SM_SENDCRYSTALEXP, 0, 0, 0, 0, (m_CrystalExp).ToString() + "/"
                        + (m_CrystalMaxExp).ToString() + "/" + (m_CrystalNGMaxExp).ToString());// 发送天地结晶内功经验
                }
            }
        }

        /// <summary>
        /// 客户端查询玩家名称
        /// </summary>
        /// <param name="Target"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        private void ClientQueryUserName(TBaseObject Target, int x, int y)
        {
            string uname;
            int TagColor;
            if (this.CretInNearXY(Target, x, y))
            {
                TagColor = this.GetCharColor(Target);
                m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_USERNAME, Target.m_ActorsId, TagColor, 0, 0, 0);
                uname = Target.GetShowName();
                SendSocket(this.m_DefMsg, EncryptUnit.EncodeString(uname));
            }
            else
            {
                SendDefMessage(Grobal2.SM_GHOST, Target.m_ActorsId, x, y, 0, "");
            }
        }


        private unsafe bool ClientHitXY(int wIdent, int nX, int nY, int nDir, bool boLateDelivery, ref uint dwDelayTime)
        {
            bool result = false;
            int n14 = 0;
            int n18 = 0;
            TStdItem StdItem;
            uint dwAttackTime = 0;
            uint dwCheckTime = 0;
            const string sExceptionMsg = "[异常] TPlayObject::ClientHitXY";
            dwDelayTime = 0;
            try
            {
                if (!m_boCanHit)
                {
                    return result;
                }
                if (this.m_boDeath || ((this.m_wStatusTimeArr[Grobal2.POISON_STONE] != 0) && !M2Share.g_Config.ClientConf.boParalyCanHit))
                {
                    return result;
                }
                // 防麻
                if (!boLateDelivery)
                {
                    if (!CheckActionStatus(wIdent, ref dwDelayTime))
                    {
                        m_boFilterAction = false;
                        return result;
                    }
                    m_boFilterAction = true;
                    dwAttackTime = (uint)HUtil32._MAX(0, ((int)M2Share.g_Config.dwHitIntervalTime) -
                        this.m_nHitSpeed * M2Share.g_Config.ClientConf.btItemSpeed);// 防止负数出错  武器速度控制
                    dwCheckTime = HUtil32.GetTickCount() - m_dwAttackTick;
                    if (dwCheckTime < dwAttackTime)
                    {
                        m_dwAttackCount++;
                        dwDelayTime = dwAttackTime - dwCheckTime;
                        if (dwDelayTime > M2Share.g_Config.dwDropOverSpeed)
                        {
                            if (m_dwAttackCount >= 4)
                            {
                                m_dwAttackTick = HUtil32.GetTickCount();
                                m_dwAttackCount = 0;
                                dwDelayTime = M2Share.g_Config.dwDropOverSpeed;
                                if (m_boTestSpeedMode)
                                {
                                    this.SysMsg("攻击忙复位！！！" + (dwDelayTime).ToString(), TMsgColor.c_Red, TMsgType.t_Hint);
                                }
                            }
                            else
                            {
                                m_dwAttackCount = 0;
                            }
                            return result;
                        }
                        else
                        {
                            if (m_boTestSpeedMode)
                            {
                                this.SysMsg("攻击步忙！！！" + (dwDelayTime).ToString(), TMsgColor.c_Red, TMsgType.t_Hint);
                            }
                            return result;
                        }
                    }
                }
                if ((nX == this.m_nCurrX) && (nY == this.m_nCurrY))
                {
                    result = true;
                    m_dwAttackTick = HUtil32.GetTickCount();
                    if ((wIdent == Grobal2.CM_HEAVYHIT) && (this.m_UseItems[Grobal2.U_WEAPON].Dura > 0))  // 挖矿
                    {
                        if (M2Share.g_Config.boStartMapEvent)// 开启地图解发
                        {
                            if (this.m_btRaceServer == Grobal2.RC_PLAYOBJECT)
                            {
                                StartMapEventOfMine();  // 挖矿事件触发
                            }
                        }
                        if (this.GetFrontPosition(ref n14, ref n18) && !this.m_PEnvir.CanWalk(n14, n18, false))
                        {
                            if (this.m_UseItems[Grobal2.U_WEAPON] != null)
                            {
                                StdItem = M2Share.UserEngine.GetStdItem(this.m_UseItems[Grobal2.U_WEAPON].wIndex);
                                if ((StdItem != null) && (StdItem.Shape == 19))
                                {
                                    if (PileStones(n14, n18))
                                    {
                                        SendSocket(null, "=DIG");
                                    }
                                    this.m_nHealthTick -= 30;
                                    this.m_nSpellTick -= 50;
                                    this.m_nSpellTick = HUtil32._MAX(0, this.m_nSpellTick);
                                    this.m_nPerHealth -= 2;
                                    this.m_nPerSpell -= 2;
                                    return result;
                                }
                            }
                        }
                    }
                    if (wIdent == Grobal2.CM_HIT)
                    {
                        this.AttackDir(null, 0, nDir);
                    }
                    if (wIdent == Grobal2.CM_HEAVYHIT)
                    {
                        this.AttackDir(null, 1, nDir);
                    }
                    if (wIdent == Grobal2.CM_BIGHIT)
                    {
                        this.AttackDir(null, 2, nDir);
                    }
                    if ((wIdent == Grobal2.CM_POWERHIT) && (this.m_MagicArr[0][MagicConst.SKILL_YEDO] != null))
                    {
                        this.AttackDir(null, 3, nDir);
                    }
                    // 攻杀
                    if ((wIdent == Grobal2.CM_LONGHIT) && (this.m_MagicArr[0][MagicConst.SKILL_ERGUM] != null))
                    {
                        this.AttackDir(null, 4, nDir);
                    }
                    if ((wIdent == Grobal2.CM_WIDEHIT) && (this.m_MagicArr[0][MagicConst.SKILL_BANWOL] != null))
                    {
                        this.AttackDir(null, 5, nDir);
                    }
                    if ((wIdent == Grobal2.CM_FIREHIT) && (this.m_MagicArr[0][MagicConst.SKILL_FIRESWORD] != null))
                    {
                        this.AttackDir(null, 7, nDir);
                    }
                    // 普通烈火
                    if ((wIdent == Grobal2.CM_4FIREHIT) && (this.m_MagicArr[0][MagicConst.SKILL_FIRESWORD] != null))
                    {
                        this.AttackDir(null, 7, nDir);
                    }
                    // 4级烈火
                    if ((wIdent == Grobal2.CM_CRSHIT) && (this.m_MagicArr[0][MagicConst.SKILL_40] != null))
                    {
                        this.AttackDir(null, 8, nDir);
                    }
                    // 抱月
                    if ((wIdent == Grobal2.CM_TWNHIT) && (this.m_MagicArr[0][MagicConst.SKILL_42] != null))
                    {
                        this.AttackDir(null, 9, nDir);
                    }
                    // 开天斩重击
                    if ((wIdent == Grobal2.CM_QTWINHIT) && (this.m_MagicArr[0][MagicConst.SKILL_42] != null))
                    {
                        this.AttackDir(null, 9, nDir);
                    }
                    // 开天斩轻击
                    if ((wIdent == Grobal2.CM_CIDHIT) && (this.m_MagicArr[0][MagicConst.SKILL_43] != null))
                    {
                        this.AttackDir(null, 12, nDir);
                    }
                    // 龙影剑法
                    if ((wIdent == Grobal2.CM_SANJUEHIT) && (this.m_MagicArr[0][MagicConst.SKILL_76] != null))
                    {
                        this.AttackDir(null, 14, nDir);
                    }
                    // 三绝杀
                    if ((wIdent == Grobal2.CM_ZHUIXINHIT) && (this.m_MagicArr[0][MagicConst.SKILL_79] != null))
                    {
                        this.AttackDir(null, 15, nDir);
                    }
                    // 追心刺
                    if ((wIdent == Grobal2.CM_DUANYUEHIT) && (this.m_MagicArr[0][MagicConst.SKILL_82] != null))
                    {
                        this.AttackDir(null, 16, nDir);
                    }
                    // 断岳斩
                    if ((wIdent == Grobal2.CM_HENGSAOHIT) && (this.m_MagicArr[0][MagicConst.SKILL_85] != null))
                    {
                        this.AttackDir(null, 17, nDir);
                    }
                    // 横扫千军
                    if ((wIdent == Grobal2.CM_YTPDHIT) && (this.m_MagicArr[0][MagicConst.SKILL_69] != null))
                    {
                        this.AttackDir(null, 18, nDir);
                    }
                    // 倚天劈地
                    if ((wIdent == Grobal2.CM_XPYJHIT) && (this.m_MagicArr[0][MagicConst.SKILL_96] != null))
                    {
                        this.AttackDir(null, 21, nDir);
                    }
                    // 血魄一击 
                    if ((wIdent == Grobal2.CM_4LONGHIT) && (this.m_MagicArr[0][MagicConst.SKILL_89] != null))
                    {
                        this.AttackDir(null, 19, nDir);
                    }
                    // 四级刺杀
                    if ((wIdent == Grobal2.CM_YUANYUEHIT) && (this.m_MagicArr[0][MagicConst.SKILL_90] != null))
                    {
                        this.AttackDir(null, 20, nDir);
                    }
                    // 圆月弯刀
                    if (wIdent == Grobal2.CM_42HIT)
                    {
                        this.AttackDir(null, 10, nDir);
                    }
                    if (wIdent == Grobal2.CM_42HIT)
                    {
                        this.AttackDir(null, 11, nDir);
                    }
                    if ((wIdent == Grobal2.CM_DAILY) && (this.m_MagicArr[0][MagicConst.SKILL_74] != null))
                    {
                        this.AttackDir(null, 13, nDir);
                    }
                    // 逐日剑法
                    if (!this.m_boUseBatter)
                    {
                        // 连击不使用攻杀 
                        if ((this.m_MagicArr[0][MagicConst.SKILL_YEDO] != null) && (this.m_UseItems[Grobal2.U_WEAPON].Dura > 0))
                        {
                            // 攻杀随机放出
                            this.m_btAttackSkillCount -= 1;
                            if (this.m_btAttackSkillPointCount == this.m_btAttackSkillCount)
                            {
                                this.m_boPowerHit = true;
                                SendSocket(null, "+PWR");
                            }
                            if (this.m_btAttackSkillCount <= 0)
                            {
                                this.m_btAttackSkillCount = Convert.ToByte(7 - this.m_MagicArr[0][MagicConst.SKILL_YEDO].btLevel);
                                this.m_btAttackSkillPointCount = (byte)HUtil32.Random(this.m_btAttackSkillCount);
                            }
                        }
                    }
                    this.m_nHealthTick -= 30;
                    this.m_nSpellTick -= 100;
                    this.m_nSpellTick = HUtil32._MAX(0, this.m_nSpellTick);
                    this.m_nPerHealth -= 2;
                    this.m_nPerSpell -= 2;
                }
            }
            catch
            {
                M2Share.MainOutMessage(sExceptionMsg);
            }
            return result;
        }

        /// <summary>
        /// 客户端骑马攻击
        /// </summary>
        /// <returns></returns>
        private bool ClientHorseRunXY(int wIdent, int nX, int nY, bool boLateDelivery, ref uint dwDelayTime)
        {
            bool result;
            int n14;
            uint dwCheckTime;
            result = false;
            dwDelayTime = 0;
            if (!m_boCanRun)
            {
                return result;
            }
            if (this.m_boDeath || ((this.m_wStatusTimeArr[Grobal2.POISON_STONE] != 0) && !M2Share.g_Config.ClientConf.boParalyCanRun))// 5
            {
                return result;
            }
            if (!boLateDelivery) // 防麻
            {
                if (!CheckActionStatus(wIdent, ref dwDelayTime))
                {
                    m_boFilterAction = false;
                    return result;
                }
                m_boFilterAction = true;
                dwCheckTime = HUtil32.GetTickCount() - m_dwMoveTick;
                if (dwCheckTime < M2Share.g_Config.dwRunIntervalTime)
                {
                    m_dwMoveCount++;
                    dwDelayTime = M2Share.g_Config.dwRunIntervalTime - dwCheckTime;
                    if (dwDelayTime > M2Share.g_Config.dwDropOverSpeed)
                    {
                        if (m_dwMoveCount >= 4)
                        {

                            m_dwMoveTick = HUtil32.GetTickCount();
                            m_dwMoveCount = 0;
                            dwDelayTime = M2Share.g_Config.dwDropOverSpeed;
                            if (m_boTestSpeedMode)
                            {
                                this.SysMsg("马跑步忙复位！！！" + (dwDelayTime).ToString(), TMsgColor.c_Red, TMsgType.t_Hint);
                            }
                        }
                        else
                        {
                            m_dwMoveCount = 0;
                        }
                        return result;
                    }
                    else
                    {
                        if (m_boTestSpeedMode)
                        {
                            this.SysMsg("马跑步忙！！！" + (dwDelayTime).ToString(), TMsgColor.c_Red, TMsgType.t_Hint);
                        }
                        return result;
                    }
                }
            }

            m_dwMoveTick = HUtil32.GetTickCount();
            this.m_bo316 = false;
            this.SysMsg(string.Format("当前X:{0} 当前Y:{1} 目标X:{2} 目标Y:{3}", this.m_nCurrX, this.m_nCurrY, nX, nY), TMsgColor.c_Green, TMsgType.t_Hint);
            n14 = M2Share.GetNextDirection(this.m_nCurrX, this.m_nCurrY, nX, nY);
            if (HorseRunTo((byte)n14, false))
            {
                this.m_dwStationTick = HUtil32.GetTickCount();// 增加检测人物站立时间
                if (this.m_boTransparent && (this.m_boHideMode))// 0
                {
                    this.m_wStatusTimeArr[Grobal2.STATE_TRANSPARENT] = 1;
                }
                if (this.m_bo316 || ((this.m_nCurrX == nX) && (this.m_nCurrY == nY)))
                {
                    result = true;
                }
                this.m_nHealthTick -= 60;
                this.m_nSpellTick -= 10;
                this.m_nSpellTick = HUtil32._MAX(0, this.m_nSpellTick);
                this.m_nPerHealth -= 1;
                this.m_nPerSpell -= 1;
            }
            else
            {
                m_dwMoveCount = 0;
                m_dwMoveCountA = 0;
            }
            return result;
        }

        /// <summary>
        /// 客户端攻击目标
        /// </summary>
        /// <returns></returns>
        private unsafe bool ClientSpellXY(ushort wIdent, int nKey, int nTargetX, int nTargetY, TBaseObject TargeTBaseObject, bool boLateDelivery, ref uint dwDelayTime)
        {
            bool result;
            TUserMagic UserMagic;
            int nSpellPoint;
            int n14;
            TBaseObject BaseObject;
            uint dwCheckTime;
            bool boIsWarrSkill;
            const string sDisableMagicCross = "当前地图不允许使用：{0}";
            result = false;
            dwDelayTime = 0;
            this.m_nCurrBatterMagicID = 0;
            if (!(this.m_boUseBatter && (wIdent >= 76 && wIdent <= 87)))
            {
                if (!m_boCanSpell)// 不可以使用魔法，但可以使用连击技 
                {
                    return result;
                }
            }
            if (this.m_boDeath || ((this.m_wStatusTimeArr[Grobal2.POISON_STONE] != 0) && !M2Share.g_Config.ClientConf.boParalyCanSpell)) // 防麻
            {
                return result;
            }
            if (this.m_boUseBatter)// 连击使用wIdle获得魔法 
            {
                UserMagic = GetMagicInfo(wIdent);
            }
            else
            {
                UserMagic = GetMagicInfo(nKey);
            }
            if (UserMagic == null)
            {
                return result;
            }
            this.m_nCurrBatterMagicID = UserMagic.wMagIdx;
            if (this.m_PEnvir != null)
            {
                if (!this.m_PEnvir.AllowMagics(UserMagic.MagicInfo.sMagicName))
                {
                    this.SysMsg(string.Format(sDisableMagicCross, UserMagic.MagicInfo.sMagicName), TMsgColor.c_Red, TMsgType.t_Notice);
                    return result;
                }
            }
            boIsWarrSkill = M2Share.MagicManager.IsWarrSkill(UserMagic.wMagIdx);
            if (!boLateDelivery && !boIsWarrSkill)
            {
                if (!CheckActionStatus(wIdent, ref dwDelayTime))
                {
                    m_boFilterAction = false;
                    return result;
                }
                m_boFilterAction = true;
                dwCheckTime = HUtil32.GetTickCount() - m_dwMagicAttackTick;
                if (dwCheckTime < m_dwMagicAttackInterval)
                {
                    m_dwMagicAttackCount++;
                    dwDelayTime = m_dwMagicAttackInterval - dwCheckTime;
                    if (dwDelayTime > M2Share.g_Config.dwMagicHitIntervalTime / 3)
                    {
                        if (m_dwMagicAttackCount >= 4)
                        {
                            m_dwMagicAttackTick = HUtil32.GetTickCount();
                            m_dwMagicAttackCount = 0;
                            dwDelayTime = M2Share.g_Config.dwMagicHitIntervalTime / 3;
                            if (m_boTestSpeedMode)
                            {
                                this.SysMsg("魔法忙复位！！！" + dwDelayTime, TMsgColor.c_Red, TMsgType.t_Hint);
                            }
                        }
                        else
                        {
                            m_dwMagicAttackCount = 0;
                        }
                        return result;
                    }
                    else
                    {
                        if (m_boTestSpeedMode)
                        {
                            this.SysMsg("魔法忙！！！" + dwDelayTime, TMsgColor.c_Red, TMsgType.t_Hint);
                        }
                        return result;
                    }
                }
            }
            this.m_nSpellTick -= 450;
            this.m_nSpellTick = HUtil32._MAX(0, this.m_nSpellTick);
            if (!boIsWarrSkill)
            {
                m_dwMagicAttackInterval = UserMagic.MagicInfo.dwDelayTime + M2Share.g_Config.dwMagicHitIntervalTime;
            }
            m_dwMagicAttackTick = HUtil32.GetTickCount();
            switch (UserMagic.wMagIdx)
            {
                case MagicConst.SKILL_ERGUM:// 12 刺杀剑法
                    if (this.m_MagicArr[0][MagicConst.SKILL_ERGUM] != null)
                    {
                        if (!this.m_boUseThrusting)
                        {
                            this.ThrustingOnOff(true);
                            SendSocket(null, "+LNG");
                        }
                        else
                        {
                            this.ThrustingOnOff(false);
                            SendSocket(null, "+ULNG");
                        }
                    }
                    result = true;
                    break;
                case MagicConst.SKILL_BANWOL:// 25 半月弯刀
                    if (this.m_MagicArr[0][MagicConst.SKILL_BANWOL] != null)
                    {
                        if (!this.m_boUseHalfMoon)
                        {
                            this.HalfMoonOnOff(true);
                            SendSocket(null, "+WID");
                        }
                        else
                        {
                            this.HalfMoonOnOff(false);
                            SendSocket(null, "+UWID");
                        }
                    }
                    result = true;
                    break;
                case MagicConst.SKILL_90:// 90 圆月弯刀
                    if (this.m_MagicArr[0][MagicConst.SKILL_90] != null)
                    {
                        if (!this.m_bo90Kill)
                        {
                            this.YuanYueOnOff(true);
                            SendSocket(null, "+YUE");
                        }
                        else
                        {
                            this.YuanYueOnOff(false);
                            SendSocket(null, "+UYUE");
                        }
                    }
                    result = true;
                    break;
                case MagicConst.SKILL_FIRESWORD:// 26 烈火剑法  人物的技能
                    if (this.m_MagicArr[0][MagicConst.SKILL_FIRESWORD] != null)
                    {
                        if (this.AllowFireHitSkill())
                        {
                            nSpellPoint = GetSpellPoint(UserMagic);
                            if (this.m_WAbil.MP >= nSpellPoint)
                            {
                                if (nSpellPoint > 0)
                                {
                                    this.DamageSpell(nSpellPoint);
                                    this.HealthSpellChanged();
                                }
                                if (this.m_btRaceServer == Grobal2.RC_HEROOBJECT)
                                {
                                    //if ((this.m_MagicFireSwordSkill.btLevel == 4) && (((THeroObject)(this)).m_nLoyal >= M2Share.g_Config.nGotoLV4))
                                    //{
                                    //    SendSocket(null, "+4FIR");
                                    //}
                                    //else
                                    //{
                                    //    SendSocket(null, "+FIR");
                                    //}
                                }
                                else
                                {
                                    if ((this.m_MagicArr[0][MagicConst.SKILL_FIRESWORD].btLevel == 4))
                                    {
                                        // 4级烈火 20100317
                                        SendSocket(null, "+4FIR");
                                    }
                                    else
                                    {
                                        SendSocket(null, "+FIR");
                                    }
                                }
                            }
                        }
                    }
                    result = true;
                    break;
                case MagicConst.SKILL_74:// 逐日剑法
                    if (this.m_MagicArr[0][MagicConst.SKILL_74] != null)
                    {
                        if (this.AllowDailySkill())
                        {
                            nSpellPoint = GetSpellPoint(UserMagic);
                            if (this.m_WAbil.MP >= nSpellPoint)
                            {
                                if (nSpellPoint > 0)
                                {
                                    this.DamageSpell(nSpellPoint);
                                    this.HealthSpellChanged();
                                }
                                SendSocket(null, "+DAILY");
                            }
                        }
                    }
                    result = true;
                    break;
                case MagicConst.SKILL_MOOTEBO:// 野蛮冲撞
                    result = true;
                    if ((HUtil32.GetTickCount() - m_dwDoMotaeboTick) > 3000)  // 3 * 1000
                    {
                        m_dwDoMotaeboTick = HUtil32.GetTickCount();
                        this.m_btDirection = (byte)nTargetX;
                        nSpellPoint = GetSpellPoint(UserMagic);
                        if (this.m_WAbil.MP >= nSpellPoint)
                        {
                            if (nSpellPoint > 0)
                            {
                                this.DamageSpell(nSpellPoint);
                                this.HealthSpellChanged();
                            }
                            if (DoMotaebo(this.m_btDirection, UserMagic.btLevel))
                            {
                                if (UserMagic.btLevel < 3)
                                {
                                    if (UserMagic.MagicInfo.TrainLevel[UserMagic.btLevel] < this.m_Abil.Level)
                                    {
                                        this.TrainSkill(UserMagic, HUtil32.Random(3) + 1);
                                        if (!this.CheckMagicLevelup(UserMagic))
                                        {
                                            this.SendDelayMsg(this, Grobal2.RM_MAGIC_LVEXP, 0, UserMagic.MagicInfo.wMagicId, UserMagic.btLevel, UserMagic.nTranPoint, "", 1000);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    break;
                case MagicConst.SKILL_40:
                    // 抱月刀法
                    if (this.m_MagicArr[0][MagicConst.SKILL_40] != null)
                    {
                        if (!this.m_boCrsHitkill)
                        {
                            this.SkillCrsOnOff(true);
                            SendSocket(null, "+CRS");
                        }
                        else
                        {
                            this.SkillCrsOnOff(false);
                            SendSocket(null, "+UCRS");
                        }
                    }
                    result = true;
                    break;
                case 43:// 开天斩
                    if (this.m_MagicArr[0][MagicConst.SKILL_42] != null)
                    {
                        if (this.Skill42OnOff())
                        {
                            nSpellPoint = GetSpellPoint(UserMagic);
                            if (this.m_WAbil.MP >= nSpellPoint)
                            {
                                if (nSpellPoint > 0)
                                {
                                    this.DamageSpell(nSpellPoint);
                                    this.HealthSpellChanged();
                                }
                                if (HUtil32.Random(M2Share.g_Config.n43KillHitRate) == 0) // 增加 开天轻击
                                {
                                    this.m_n42kill = 2;
                                    SendSocket(null, "+TWN");
                                }
                                else
                                {
                                    this.m_n42kill = 1;
                                    SendSocket(null, "+QTWN");// 轻击
                                }
                            }
                        }
                    }
                    result = true;
                    break;
                case 42:// 龙影剑法(破空剑)
                    if (this.m_MagicArr[0][MagicConst.SKILL_43] != null)
                    {
                        if (this.Skill43OnOff())
                        {
                            nSpellPoint = GetSpellPoint(UserMagic);
                            if (this.m_WAbil.MP >= nSpellPoint)
                            {
                                if (nSpellPoint > 0)
                                {
                                    this.DamageSpell(nSpellPoint);
                                    this.HealthSpellChanged();
                                }
                                SendSocket(null, "+CID");
                            }
                        }
                    }
                    result = true;
                    break;
                case MagicConst.SKILL_76:// 三绝杀
                    if (this.m_MagicArr[0][MagicConst.SKILL_76] != null)
                    {
                        SendSocket(null, "+SJUE");
                    }
                    break;
                case MagicConst.SKILL_79:// 追心刺
                    if (this.m_MagicArr[0][MagicConst.SKILL_79] != null)
                    {
                        SendSocket(null, "+ZXIN");
                    }
                    break;
                case MagicConst.SKILL_82:// 断岳斩
                    if (this.m_MagicArr[0][MagicConst.SKILL_82] != null)
                    {
                        SendSocket(null, "+DYUE");
                    }
                    break;
                case MagicConst.SKILL_85:// 横扫千军
                    if (this.m_MagicArr[0][MagicConst.SKILL_85] != null)
                    {
                        SendSocket(null, "+HSAO");
                    }
                    break;
                case MagicConst.SKILL_69:
                    // 倚天劈地
                    if (this.m_MagicArr[0][MagicConst.SKILL_69] != null)
                    {
                        if (this.AllowYTPDHitSkill())
                        {
                            SendSocket(null, "+YTPD");
                        }
                    }
                    result = true;
                    break;
                case MagicConst.SKILL_96:
                    // 血魄一击
                    if (this.m_MagicArr[0][MagicConst.SKILL_96] != null)
                    {
                        if (this.AllowXPYJHitSkill())
                        {
                            SendSocket(null, "+XPYJ");
                        }
                    }
                    result = true;
                    break;
                default:
                    n14 = M2Share.GetNextDirection(this.m_nCurrX, this.m_nCurrY, nTargetX, nTargetY);
                    this.m_btDirection = (byte)n14;
                    BaseObject = null;
                    // 检查目标角色，与目标座标误差范围，如果在误差范围内则修正目标座标
                    // 修正目标坐标 就是耙子的目标 不是修改目标对象的位子
                    if (HUtil32.rangeInDefined(UserMagic.wMagIdx, 60, 65))
                    {
                        if (this.CretInNearXY(TargeTBaseObject, nTargetX, nTargetY, 12))
                        {
                            BaseObject = TargeTBaseObject;
                            nTargetX = BaseObject.m_nCurrX;
                            nTargetY = BaseObject.m_nCurrY;
                        }
                    }
                    else
                    {
                        if (this.CretInNearXY(TargeTBaseObject, nTargetX, nTargetY))
                        {
                            BaseObject = TargeTBaseObject;
                            nTargetX = BaseObject.m_nCurrX;
                            nTargetY = BaseObject.m_nCurrY;
                        }
                    }
                    if (!DoSpell(UserMagic, nTargetX, nTargetY, BaseObject))
                    {
                        this.SendRefMsg(Grobal2.RM_MAGICFIREFAIL, 0, 0, 0, 0, "");
                    }
                    result = true;
                    break;
            }
            if (result && this.m_boUseBatter)
            {
                if ((new ArrayList(new int[] { 77, 78, 80, 81, 83, 84, 86, 87 }).Contains(this.m_nCurrBatterMagicID)))
                {
                    this.m_boBatterFinally = true;
                }
            }
            return result;
        }

        private bool ClientRunXY(int wIdent, int nX, int nY, int nFlag, ref uint dwDelayTime)
        {
            bool result = false;
            int nDir;
            uint dwCheckTime;
            dwDelayTime = 0;
            if (!m_boCanRun)
            {
                return result;
            }
            if (this.m_boDeath || ((this.m_wStatusTimeArr[Grobal2.POISON_STONE] != 0) && !M2Share.g_Config.ClientConf.boParalyCanRun))
            {
                return result;
            }
            if (nFlag != wIdent)// 防麻
            {
                if (!CheckActionStatus(wIdent, ref dwDelayTime))
                {
                    m_boFilterAction = false;
                    return result;
                }
                m_boFilterAction = true;
                dwCheckTime = HUtil32.GetTickCount() - m_dwMoveTick;
                if (dwCheckTime < M2Share.g_Config.dwRunIntervalTime)
                {
                    m_dwMoveCount++;
                    dwDelayTime = M2Share.g_Config.dwRunIntervalTime - dwCheckTime;
                    if (dwDelayTime > M2Share.g_Config.dwRunIntervalTime / 3)
                    {
                        if (m_dwMoveCount >= 4)
                        {
                            m_dwMoveTick = HUtil32.GetTickCount();
                            m_dwMoveCount = 0;
                            dwDelayTime = M2Share.g_Config.dwRunIntervalTime / 3;
                            if (m_boTestSpeedMode)
                            {
                                this.SysMsg("跑步忙复位！！！" + (dwDelayTime).ToString(), TMsgColor.c_Red, TMsgType.t_Hint);
                            }
                        }
                        else
                        {
                            m_dwMoveCount = 0;
                        }
                        return result;
                    }
                    else
                    {
                        if (m_boTestSpeedMode)
                        {
                            this.SysMsg("跑步忙！！！" + (dwDelayTime).ToString(), TMsgColor.c_Red, TMsgType.t_Hint);
                        }
                        return result;
                    }
                }
            }
            m_dwMoveTick = HUtil32.GetTickCount();
            this.m_bo316 = false;
            nDir = M2Share.GetNextDirection(this.m_nCurrX, this.m_nCurrY, nX, nY);
            if (this.RunTo((byte)nDir, false, nX, nY))
            {
                this.m_dwStationTick = HUtil32.GetTickCount();// 增加检测人物站立不动时间
                if (this.m_boTransparent && (this.m_boHideMode))
                {
                    this.m_wStatusTimeArr[Grobal2.STATE_TRANSPARENT] = 1;
                }
                if (this.m_bo316 || ((this.m_nCurrX == nX) && (this.m_nCurrY == nY)))
                {
                    result = true;
                }
                this.m_nHealthTick -= 60;// 原来跑步还得减少加血加魔的间隔
                this.m_nSpellTick -= 10;
                this.m_nSpellTick = HUtil32._MAX(0, this.m_nSpellTick);
                this.m_nPerHealth -= 1;// 加血的点数也给少了下去 不看代码真的不知道啊
                this.m_nPerSpell -= 1;
            }
            else
            {
                m_dwMoveCount = 0;
                m_dwMoveCountA = 0;
            }
            return result;
        }

        private bool ClientWalkXY(int wIdent, int nX, int nY, bool boLateDelivery, ref uint dwDelayTime)
        {
            bool result = false;
            int n14;
            uint dwCheckTime;
            dwDelayTime = 0;
            if (!m_boCanWalk)
            {
                return result;
            }
            if (this.m_boDeath || ((this.m_wStatusTimeArr[Grobal2.POISON_STONE] != 0) && !M2Share.g_Config.ClientConf.boParalyCanWalk))
            {
                return result;
            }
            // 防麻
            if (!boLateDelivery)
            {
                if (!CheckActionStatus(wIdent, ref dwDelayTime))
                {
                    m_boFilterAction = false;
                    return result;
                }
                m_boFilterAction = true;
                dwCheckTime = HUtil32.GetTickCount() - m_dwMoveTick;
                if (dwCheckTime < M2Share.g_Config.dwWalkIntervalTime)
                {
                    m_dwMoveCount++;
                    dwDelayTime = M2Share.g_Config.dwWalkIntervalTime - dwCheckTime;
                    if (dwDelayTime > M2Share.g_Config.dwWalkIntervalTime / 3)
                    {
                        if (m_dwMoveCount >= 4)
                        {
                            m_dwMoveTick = HUtil32.GetTickCount();
                            m_dwMoveCount = 0;
                            dwDelayTime = M2Share.g_Config.dwWalkIntervalTime / 3;
                            if (m_boTestSpeedMode)
                            {
                                this.SysMsg("走路忙复位！！！" + dwDelayTime, TMsgColor.c_Red, TMsgType.t_Hint);
                            }
                        }
                        else
                        {
                            m_dwMoveCount = 0;
                        }
                        return result;
                    }
                    else
                    {
                        if (m_boTestSpeedMode)
                        {
                            this.SysMsg("走路忙！！！" + dwDelayTime, TMsgColor.c_Red, TMsgType.t_Hint);
                        }
                        return result;
                    }
                }
            }
            m_dwMoveTick = HUtil32.GetTickCount();
            this.m_bo316 = false;
            n14 = M2Share.GetNextDirection(this.m_nCurrX, this.m_nCurrY, nX, nY);
            if (!m_boClientFlag)
            {
                if ((n14 == 0) && (m_nStep == 0))
                {
                    m_nStep++;
                }
                else if ((n14 == 4) && (m_nStep == 1))
                {
                    m_nStep++;
                }
                else if ((n14 == 6) && (m_nStep == 2))
                {
                    m_nStep++;
                }
                else if ((n14 == 2) && (m_nStep == 3))
                {
                    m_nStep++;
                }
                else if ((n14 == 1) && (m_nStep == 4))
                {
                    m_nStep++;
                }
                else if ((n14 == 5) && (m_nStep == 5))
                {
                    m_nStep++;
                }
                else if ((n14 == 7) && (m_nStep == 6))
                {
                    m_nStep++;
                }
                else if ((n14 == 3) && (m_nStep == 7))
                {
                    m_nStep++;
                }
                else
                {
                    m_nStep = 0;
                }
            }
            if (this.WalkTo((byte)n14, false))
            {
                this.m_dwStationTick = HUtil32.GetTickCount();// 增加检测人物站立不动时间
                if (this.m_bo316 || ((this.m_nCurrX == nX) && (this.m_nCurrY == nY)))
                {
                    result = true;
                }
                this.m_nHealthTick -= 10;// 走路也少加血间隔
            }
            else
            {
                m_dwMoveCount = 0;
                m_dwMoveCountA = 0;
            }
            return result;
        }

        /// <summary>
        /// 玩家点击NPC
        /// </summary>
        /// <param name="NPC"></param>
        private void ClientClickNPC(int NPC)
        {
            TNormNpc NormNpc;
            if (!m_boCanDeal)
            {
                this.SendMsg(M2Share.g_ManageNPC, Grobal2.RM_MENU_OK, 0, this.m_ActorsId, 0, 0, GameMsgDef.g_sCanotTryDealMsg);
                return;
            }
            if (this.m_boDeath || this.m_boGhost)
            {
                return;
            }
            NormNpc = M2Share.UserEngine.FindMerchant(NPC);
            if ((NormNpc.m_PEnvir == this.m_PEnvir) && (Math.Abs(NormNpc.m_nCurrX - this.m_nCurrX) <= 15) && (Math.Abs(NormNpc.m_nCurrY - this.m_nCurrY) <= 15))
            {
                if (NormNpc is TMerchant)
                {
                    NormNpc.Click(this);
                }
                else if (NormNpc is TGuildOfficial)
                {
                    NormNpc.Click(this);
                }
                else if (NormNpc is TCastleOfficial)
                {
                    NormNpc.Click(this);
                }
            }
        }

        /// <summary>
        /// 客户端查看别人的装备
        /// </summary>
        private unsafe void ClientQueryUserState(TBaseObject BaseObject, int nX, int nY)
        {
            TUserStateInfo UserState = new TUserStateInfo();
            TOUserStateInfo OUserState = new TOUserStateInfo();
            TStdItem StdItem24;
            TClientItem ClientItem = null;
            TOClientItem* OClientItem = null;
            string sUserItemName;
            TStdItem StdItem = null;
            TUserItem UserItem;
            byte boCopyHum;// 是否是分身
            byte nCode;
            nCode = 0;
            try
            {
                if (BaseObject != null)
                {
                    if (!BaseObject.m_boGhost)
                    {
                        boCopyHum = 0;
                        nCode = 1;
                        if ((m_nSoftVersionDateEx == 0) && (m_dwClientTick == 0))
                        {
                            if (!this.CretInNearXY(BaseObject, nX, nY))
                            {
                                return;
                            }
                            OUserState.feature = BaseObject.GetFeature(this);
                            HUtil32.StrToSByteArry(BaseObject.m_sCharName, OUserState.UserName, 15, ref OUserState.UserNameLen);
                            OUserState.NAMECOLOR = this.GetCharColor(BaseObject);
                            nCode = 2;
                            if (BaseObject.m_btRaceServer == Grobal2.RC_PLAYMOSTER)
                            {
                                if (BaseObject.m_Master != null)
                                {
                                    if (BaseObject.m_Master.m_btRaceServer == Grobal2.RC_PLAYOBJECT)    // 人物的分身
                                    {
                                        HUtil32.StrToSByteArry(BaseObject.m_Master.m_sCharName, UserState.GuildName, 14, ref UserState.GuildNameLen);// 人形显示主人名字
                                        boCopyHum = 1;
                                    }
                                    else if (BaseObject.m_Master.m_btRaceServer == Grobal2.RC_HEROOBJECT) // 英雄的分身
                                    {
                                        HUtil32.StrToSByteArry(BaseObject.m_Master.m_Master.m_sCharName, UserState.GuildName, 14, ref UserState.GuildNameLen);// 显示英雄主人名字
                                        boCopyHum = 2;
                                    }
                                }
                                else
                                {
                                    HUtil32.StrToSByteArry(M2Share.FilterShowName(HUtil32.SBytePtrToString(UserState.UserName, 0, UserState.UserNameLen)),
                                        UserState.UserName, 14, ref UserState.UserNameLen);// 人形怪过滤有数字的名称
                                }
                            }
                            nCode = 3;
                            if (BaseObject.m_btRaceServer == Grobal2.RC_HEROOBJECT) // 如果是英雄 那么就把行会名为主人名
                            {
                                HUtil32.StrToSByteArry(BaseObject.m_Master.m_sCharName, OUserState.GuildName, 14, ref OUserState.GuilidNameLen);
                                boCopyHum = 3;
                            }
                            else
                            {
                                if (BaseObject.m_MyGuild != null)
                                {
                                    HUtil32.StrToSByteArry(BaseObject.m_MyGuild.sGuildName, OUserState.GuildName, 14,
                                        ref OUserState.GuilidNameLen);
                                }
                                HUtil32.StrToSByteArry(BaseObject.m_sGuildRankName, OUserState.GuildRankName, 14, ref OUserState.GuildRankNameLen);
                            }
                            nCode = 4;
                            if (M2Share.g_Config.boUnKnowHum && BaseObject.IsUsesZhuLi())
                            {
                                HUtil32.StrToSByteArry("神秘人", UserState.UserName, 14, ref UserState.UserNameLen);// 带上斗笠即显示神秘人
                                HUtil32.StrToSByteArry("", UserState.GuildRankName, 16, ref UserState.GuildRankNameLen);
                                HUtil32.StrToSByteArry("", UserState.GuildName, 14, ref UserState.GuildNameLen);
                                boCopyHum = 0;
                            }
                            nCode = 5;
                            for (int i = m_UseItems.GetLowerBound(0); i <= m_UseItems.GetUpperBound(0); i++)
                            {
                                UserItem = BaseObject.m_UseItems[i];
                                if (UserItem.wIndex > 0)
                                {
                                    StdItem = M2Share.UserEngine.GetStdItem(BaseObject.m_UseItems[i].wIndex);
                                    if (StdItem == null)
                                    {
                                        continue;
                                    }
                                    StdItem24 = StdItem;
                                    M2Share.ItemUnit.GetItemAddValue(BaseObject.m_UseItems[i], StdItem24);
                                    // Move(StdItem24,ClientItem.S,SizeOf(TStdItem));
                                    ClientItem = new TClientItem();
                                    ClientItem.s = StdItem24;
                                    M2Share.CopyStdItemToOStdItem(StdItem24, &OClientItem->s);// 取自定义物品名称
                                    sUserItemName = "";
                                    if (UserItem.btValue[13] == 1)
                                    {
                                        sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                                    }
                                    if (sUserItemName != "")
                                    {
                                        HUtil32.StrToSByteArry(sUserItemName, OClientItem->s.Name, 14, ref OClientItem->s.NameLen);
                                    }
                                    OClientItem->MakeIndex = BaseObject.m_UseItems[i].MakeIndex;
                                    OClientItem->Dura = BaseObject.m_UseItems[i].Dura;
                                    OClientItem->DuraMax = BaseObject.m_UseItems[i].DuraMax;
                                    TOClientItem* pbtpl = (TOClientItem*)OUserState.UseItemsBuff;
                                    pbtpl[i] = *OClientItem;
                                }
                            }
                            nCode = 6;
                            if (((BaseObject.m_btRaceServer == Grobal2.RC_HEROOBJECT) && (boCopyHum != 0)) ||
                                ((BaseObject.m_btRaceServer == Grobal2.RC_PLAYMOSTER) && (boCopyHum == 2)))
                            {
                                this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_SENDUSERSTATE, 1, 0, 0, 0, 0);
                            }
                            else if ((boCopyHum == 1) && (BaseObject.m_btRaceServer == Grobal2.RC_PLAYMOSTER))  // 人形客户显示名字+的分身
                            {
                                this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_SENDUSERSTATE, 2, 0, 0, 0, 0);
                            }
                            else
                            {
                                this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_SENDUSERSTATE, 0, 0, 0, 0, 0);
                            }
                            byte[] data = new byte[Marshal.SizeOf(typeof(TOUserStateInfo))];
                            fixed (byte* pb = data)
                            {
                                *(TOUserStateInfo*)pb = OUserState;
                            }
                            SendSocket(this.m_DefMsg, EncryptUnit.EncodeBuffer(data, Marshal.SizeOf(typeof(TOUserStateInfo))));
                        }
                        else
                        {
                            nCode = 7;
                            if (!this.CretInNearXY(BaseObject, nX, nY))
                            {
                                return;
                            }
                            //FillChar(UserState, sizeof(TUserStateInfo), '\0');
                            UserState.feature = BaseObject.GetFeature(this);
                            HUtil32.StrToSByteArry(BaseObject.m_sCharName, UserState.UserName, 14, ref UserState.UserNameLen);
                            UserState.NameColor = this.GetCharColor(BaseObject);
                            nCode = 8;
                            if (BaseObject.m_btRaceServer == Grobal2.RC_PLAYMOSTER)
                            {
                                if (BaseObject.m_Master != null)
                                {
                                    if (BaseObject.m_Master.m_btRaceServer == Grobal2.RC_PLAYOBJECT)  // 人物的分身
                                    {
                                        HUtil32.StrToSByteArry(BaseObject.m_sCharName, UserState.GuildName, 14, ref UserState.GuildNameLen);// 人形显示主人名字
                                        boCopyHum = 1;
                                    }
                                    else if (BaseObject.m_Master.m_btRaceServer == Grobal2.RC_HEROOBJECT) // 英雄的分身
                                    {
                                        HUtil32.StrToSByteArry(BaseObject.m_Master.m_Master.m_sCharName, UserState.GuildName, 14, ref UserState.GuildNameLen);// 显示英雄主人名字
                                        boCopyHum = 2;
                                    }
                                }
                                else
                                {
                                    HUtil32.StrToSByteArry(M2Share.FilterShowName(HUtil32.SBytePtrToString(UserState.UserName, 0, UserState.UserNameLen)),
                                        UserState.UserName, 14, ref UserState.UserNameLen);// 人形怪过滤有数字的名称
                                }
                            }
                            nCode = 9;
                            if (BaseObject.m_btRaceServer == Grobal2.RC_HEROOBJECT)// 如果是英雄 那么就把行会名为主人名
                            {
                                if (M2Share.g_Config.boUnKnowHum && BaseObject.m_Master.IsUsesZhuLi())  // 主人为神秘人时
                                {
                                    HUtil32.StrToSByteArry("神秘人", UserState.GuildName, 14, ref UserState.GuildNameLen); //"神秘人";
                                }
                                else
                                {
                                    HUtil32.StrToSByteArry(BaseObject.m_Master.m_sCharName, UserState.GuildName, 14, ref UserState.GuildNameLen);
                                }
                                boCopyHum = 3;
                            }
                            else
                            {
                                if (BaseObject.m_MyGuild != null)
                                {
                                    HUtil32.StrToSByteArry(BaseObject.m_MyGuild.sGuildName, UserState.GuildName, 14, ref UserState.GuildNameLen);
                                }
                                HUtil32.StrToSByteArry(BaseObject.m_sGuildRankName, UserState.GuildRankName, 14,
                                    ref UserState.GuildRankNameLen);
                            }
                            nCode = 10;
                            if (M2Share.g_Config.boUnKnowHum && BaseObject.IsUsesZhuLi())
                            {
                                HUtil32.StrToSByteArry("神秘人", UserState.UserName, 14, ref UserState.UserNameLen);
                                HUtil32.StrToSByteArry("", UserState.GuildRankName, 16, ref UserState.GuildRankNameLen);
                                HUtil32.StrToSByteArry("", UserState.GuildName, 14, ref UserState.GuildNameLen);
                                boCopyHum = 0;
                            }
                            nCode = 11;
                            for (int i = m_UseItems.GetLowerBound(0); i <= m_UseItems.GetUpperBound(0); i++)
                            {
                                UserItem = BaseObject.m_UseItems[i];
                                if (UserItem.wIndex > 0)
                                {
                                    StdItem = M2Share.UserEngine.GetStdItem(BaseObject.m_UseItems[i].wIndex);
                                    nCode = 12;
                                    if (StdItem == null)
                                    {
                                        continue;
                                    }
                                    StdItem24 = StdItem;
                                    M2Share.ItemUnit.GetItemAddValue(BaseObject.m_UseItems[i], StdItem24);
                                    ClientItem = new TClientItem();
                                    ClientItem.s = StdItem24;
                                    nCode = 13;
                                    sUserItemName = "";// 取自定义物品名称
                                    if (UserItem.btValue[13] == 1)
                                    {
                                        sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                                    }
                                    if (UserItem.btValue[12] == 1)// 物品发光
                                    {
                                        ClientItem.s.Reserved1 = 1;
                                    }
                                    else
                                    {
                                        ClientItem.s.Reserved1 = 0;
                                    }
                                    if (sUserItemName != "")
                                    {
                                        ClientItem.s.Name = sUserItemName;
                                        // HUtil32.StrToSByteArry(sUserItemName, ClientItem.s.Name, 14, ref ClientItem.s.NameLen);
                                    }
                                    nCode = 14;
                                    ClientItem.MakeIndex = BaseObject.m_UseItems[i].MakeIndex;
                                    ClientItem.Dura = BaseObject.m_UseItems[i].Dura;
                                    ClientItem.DuraMax = BaseObject.m_UseItems[i].DuraMax;
                                    //TClientItem* pbtpl = (TClientItem*)UserState.UseItemsBuff;
                                    //pbtpl[i] = *ClientItem;
                                }
                            }
                            nCode = 15;
                            if (((BaseObject.m_btRaceServer == Grobal2.RC_HEROOBJECT) && (boCopyHum != 0)) || ((BaseObject.m_btRaceServer == Grobal2.RC_PLAYMOSTER) && (boCopyHum == 2)))
                            {
                                this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_SENDUSERSTATE, 1, 0, 0, 0, 0); // 英雄,英雄的分身
                            }
                            else if ((boCopyHum == 1) && (BaseObject.m_btRaceServer == Grobal2.RC_PLAYMOSTER))
                            {
                                this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_SENDUSERSTATE, 2, 0, 0, 0, 0); //人形客户显示名字+的分身
                            }
                            else
                            {
                                this.m_DefMsg = EncryptUnit.MakeDefaultMsg(Grobal2.SM_SENDUSERSTATE, 0, 0, 0, 0, 0);
                            }
                            byte[] data = new byte[sizeof(TUserStateInfo)];
                            fixed (byte* pb = data)
                            {
                                *(TUserStateInfo*)pb = UserState;
                            }
                            SendSocket(this.m_DefMsg, EncryptUnit.EncodeBuffer(data, sizeof(TUserStateInfo)));
                        }
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TPlayObject.ClientQueryUserState Code:" + nCode);
            }
        }

        /// <summary>
        /// 客户端打开交易NPC
        /// 选择商品分类（大类）
        /// </summary>
        private void ClientMerchantDlgSelect(int nParam1, string sMsg)
        {
            TNormNpc NPC;
            if (this.m_boDeath || this.m_boGhost)
            {
                return;
            }
            NPC = M2Share.UserEngine.FindMerchant(nParam1);
            if (NPC == null)
            {
                NPC = M2Share.UserEngine.FindMerchant(nParam1);
            }
            if (NPC == null)
            {
                return;
            }
            if (((NPC.m_PEnvir == this.m_PEnvir) && (Math.Abs(NPC.m_nCurrX - this.m_nCurrX) < 15) && (Math.Abs(NPC.m_nCurrY - this.m_nCurrY) < 15)) || (NPC.m_boIsHide))
            {
                NPC.UserSelect(this, sMsg.Trim());
            }
        }

        /// <summary>
        /// 客户端卖物品查询价格
        /// </summary>
        private void ClientMerchantQuerySellPrice(int nParam1, int nMakeIndex, string sMsg)
        {
            TUserItem UserItem;
            TUserItem UserItem18 = null;
            TMerchant Merchant;
            string sUserItemName;
            if (this.m_ItemList.Count > 0)
            {
                for (int i = 0; i < this.m_ItemList.Count; i++)
                {
                    UserItem = this.m_ItemList[i];
                    if (UserItem == null)
                    {
                        continue;
                    }
                    if (UserItem.MakeIndex == nMakeIndex)
                    {
                        sUserItemName = "";// 取自定义物品名称
                        if (UserItem.btValue[13] == 1)
                        {
                            sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                        }
                        if (sUserItemName == "")
                        {
                            sUserItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                        }
                        if (string.Compare(sUserItemName, sMsg, true) == 0)
                        {
                            UserItem18 = UserItem;
                            break;
                        }
                    }
                }
            }
            if (UserItem18 == null)
            {
                return;
            }
            Merchant = (TMerchant)M2Share.UserEngine.FindMerchant(nParam1);
            if (Merchant == null)
            {
                return;
            }
            if (((Merchant.m_PEnvir == this.m_PEnvir) && (Merchant.m_boSell) && (Math.Abs(Merchant.m_nCurrX - this.m_nCurrX) < 15) &&
                (Math.Abs(Merchant.m_nCurrY - this.m_nCurrY) < 15)))
            {
                Merchant.ClientQuerySellPrice(this, UserItem18);
            }
        }

        /// <summary>
        /// 客户端卖物品(出售物品)
        /// </summary>
        private void ClientUserSellItem(int nParam1, int nMakeIndex, string sMsg)
        {
            TUserItem UserItem;
            TMerchant Merchant;
            string sUserItemName;
            TStdItem StdItem;
            m_boCanQueryBag = true;// 出售物品时,不能刷新包裹
            try
            {
                for (int i = this.m_ItemList.Count - 1; i >= 0; i--)
                {
                    if (this.m_ItemList.Count <= 0)
                    {
                        break;
                    }
                    UserItem = this.m_ItemList[i];
                    if ((UserItem != null) && (UserItem.MakeIndex == nMakeIndex))
                    {
                        sUserItemName = "";// 取自定义物品名称
                        if (UserItem.btValue[13] == 1)
                        {
                            sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                        }
                        if (sUserItemName == "")
                        {
                            sUserItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                        }
                        if (string.Compare(sUserItemName, sMsg, true) == 0)
                        {
                            if (this.CheckItemValue(UserItem, 4) || this.PlugOfCheckCanItem(1, sUserItemName, true, 0, 0))// 禁止物品规则(禁止交易)
                            {
                                this.SendMsg(this, Grobal2.RM_USERSELLITEM_FAIL, 0, 0, 0, 0, "");// 出售失败消息
                                break;
                            }
                            Merchant = (TMerchant)M2Share.UserEngine.FindMerchant(nParam1);
                            if ((Merchant != null))
                            {
                                if ((Merchant.m_boSell) && ((Merchant.m_PEnvir == this.m_PEnvir) && (Math.Abs(Merchant.m_nCurrX - this.m_nCurrX) < 15) && (Math.Abs(Merchant.m_nCurrY - this.m_nCurrY) < 15)))
                                {
                                    if (Merchant.ClientSellItem(this, UserItem))
                                    {
                                        StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                        if ((StdItem != null) && (StdItem.StdMode == 51) && (StdItem.Shape == 0) && (UserItem.Dura > 0) && (UserItem.btValue[20] == 1)) // 是聚灵珠
                                        {
                                            m_DealCreat.n_UsesItemTick = 0;// 时间初始
                                            UserItem.btValue[12] = 2;// 不能聚集的标识
                                        }
                                        if (UserItem.btValue[13] == 1)
                                        {
                                            M2Share.ItemUnit.DelCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                                            UserItem.btValue[13] = 0;
                                        }
                                       UserItem=null;//物品加到NPC物品列表中了
                                        this.m_ItemList.RemoveAt(i);
                                        this.WeightChanged();
                                    }
                                }
                            }
                            break;
                        }
                    }
                }
            }
            finally
            {
                m_boCanQueryBag = false;// 出售物品时,不能刷新包裹
            }
        }

        /// <summary>
        /// 客户端购买物品
        /// </summary>
        private void ClientUserBuyItem(int nIdent, int nParam1, int nInt, int nZz, string sMsg)
        {
            TMerchant Merchant;
            try
            {
                if (m_boDealing)
                {
                    return;
                }
                Merchant = (TMerchant)M2Share.UserEngine.FindMerchant(nParam1);
                if ((Merchant == null) || (!Merchant.m_boBuy) || (Merchant.m_PEnvir != this.m_PEnvir) ||
                    (Math.Abs(Merchant.m_nCurrX - this.m_nCurrX) > 15) || (Math.Abs(Merchant.m_nCurrY - this.m_nCurrY) > 15))
                {
                    return;
                }
                if (nIdent == Grobal2.CM_USERBUYITEM)// 卖入物品 1014
                {
                    Merchant.ClientBuyItem(this, sMsg, nInt);
                }
                if (nIdent == Grobal2.CM_USERGETDETAILITEM)// 1015
                {
                    Merchant.ClientGetDetailGoodsList(this, sMsg, nZz);
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TPlayObject.ClientUserBuyItem wIdent = " + nIdent);
            }
        }

        /// <summary>
        /// 玩家仍金币
        /// </summary>
        /// <returns></returns>
        private bool ClientDropGold(int nGold)
        {
            bool result = false;
            if (M2Share.g_Config.boInSafeDisableDrop && this.InSafeZone())
            {
                this.SendMsg(M2Share.g_ManageNPC, Grobal2.RM_MENU_OK, 0, this.m_ActorsId, 0, 0, GameMsgDef.g_sCanotDropInSafeZoneMsg);
                return result;
            }
            if (M2Share.g_Config.boControlDropItem && (nGold < M2Share.g_Config.nCanDropGold))
            {
                this.SendMsg(M2Share.g_ManageNPC, Grobal2.RM_MENU_OK, 0, this.m_ActorsId, 0, 0, GameMsgDef.g_sCanotDropGoldMsg);
                return result;
            }
            if (!m_boCanDrop)
            {
                this.SendMsg(M2Share.g_ManageNPC, Grobal2.RM_MENU_OK, 0, this.m_ActorsId, 0, 0, GameMsgDef.g_sCanotDropItemMsg);
                return result;
            }
            if (nGold >= this.m_nGold)
            {
                return result;
            }
            this.m_nGold -= nGold;
            if (!this.DropGoldDown(nGold, false, null, this))
            {
                this.m_nGold += nGold;
            }
            this.GoldChanged();
            result = true;
            return result;
        }

        /// <summary>
        /// 玩家扔物品
        /// </summary>
        /// <returns></returns>
        private bool ClientDropItem(string sItemName, int nItemIdx)
        {
            bool result = false;
            int wIndex;
            int MakeIndex;
            TUserItem UserItem;
            TStdItem StdItem;
            string sUserItemName;
            byte nCode = 0;
            m_boCanQueryBag = true;// 扔物品时,不能刷新包裹
            try
            {
                try
                {
                    if (!m_boClientFlag)
                    {
                        if (m_nStep == 8)
                        {
                            m_nStep++;
                        }
                        else
                        {
                            m_nStep = 0;
                        }
                    }
                    nCode = 1;
                    if (M2Share.g_Config.boInSafeDisableDrop && this.InSafeZone())
                    {
                        this.SendMsg(M2Share.g_ManageNPC, Grobal2.RM_MENU_OK, 0, this.m_ActorsId, 0, 0, GameMsgDef.g_sCanotDropInSafeZoneMsg);
                        return result;
                    }
                    nCode = 2;
                    if (!m_boCanDrop)
                    {
                        this.SendMsg(M2Share.g_ManageNPC, Grobal2.RM_MENU_OK, 0, this.m_ActorsId, 0, 0, GameMsgDef.g_sCanotDropItemMsg);
                        return result;
                    }
                    if (sItemName.IndexOf(" ") > 0)
                    {
                        // 折分物品名称(信件物品的名称后面加了使用次数)
                        HUtil32.GetValidStr3(sItemName, ref sItemName, new string[] { " " });
                    }
                    nCode = 3;
                    if ((HUtil32.GetTickCount() - m_DealLastTick) > 3000)
                    {
                        for (int i = this.m_ItemList.Count - 1; i >= 0; i--)
                        {
                            if (this.m_ItemList.Count <= 0)
                            {
                                break;
                            }
                            UserItem = this.m_ItemList[i];
                            if ((UserItem != null) && (UserItem.MakeIndex == nItemIdx))
                            {
                                StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                if (StdItem == null)
                                {
                                    continue;
                                }
                                sUserItemName = "";// 取自定义物品名称
                                if (UserItem.btValue[13] == 1)
                                {
                                    sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                                }
                                if (sUserItemName == "")
                                {
                                    sUserItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                                }
                                if (string.Compare(sUserItemName, sItemName, true) == 0)
                                {
                                    nCode = 4;
                                    if (this.CheckItemValue(UserItem, 0)) // 检查物品是否禁止扔
                                    {
                                        break;
                                    }
                                    nCode = 5;
                                    if (this.PlugOfCheckCanItem(0, StdItem.Name, false, 0, 0)) // 禁止物品规则(管理插件功能)
                                    {
                                        break;
                                    }
                                    nCode = 6;
                                    if (M2Share.g_Config.boStartMapEvent)
                                    {
                                        if (this.m_btRaceServer == Grobal2.RC_PLAYOBJECT)
                                        {
                                            StartMapEventOfDropItem(sUserItemName); // 地图触发,扔物品事件
                                        }
                                    }
                                    if ((StdItem.StdMode == 51) && (StdItem.Shape == 0) && (UserItem.Dura > 0) && (UserItem.btValue[20] == 1)) // 是聚灵珠
                                    {
                                        n_UsesItemTick = 0;// 时间初始
                                        UserItem.btValue[12] = 2;// 不能聚集的标识
                                    }
                                    nCode = 7;
                                    wIndex = UserItem.wIndex;
                                    MakeIndex = UserItem.MakeIndex;
                                    nCode = 8;
                                    if (M2Share.g_Config.boControlDropItem && (StdItem.Price < M2Share.g_Config.nCanDropPrice))
                                    {
                                        nCode = 9;
                                       UserItem=null;
                                        this.m_ItemList.RemoveAt(i);
                                        nCode = 10;
                                        ClearCopyItem(0, wIndex, MakeIndex);// 清理复制品
                                        result = true;
                                        break;
                                    }
                                    nCode = 11;
                                    if (this.DropItemDown(UserItem, 3, false, false, null, this))
                                    {
                                        nCode = 12;
                                        if (UserItem != null)
                                        {
                                            Dispose(UserItem); //By John 修正此原处导致程序崩溃
                                        }
                                        nCode = 15;
                                        this.m_ItemList.RemoveAt(i);
                                        nCode = 13;
                                        ClearCopyItem(0, wIndex, MakeIndex);//清理复制品
                                        result = true;
                                        break;
                                    }
                                }
                            }
                        }
                        nCode = 14;
                        if (result)
                        {
                            this.WeightChanged();
                        }
                    }
                }
                catch
                {
                    M2Share.MainOutMessage("[异常] TPlayObject.ClientDropItem Code:" + nCode);
                }
            }
            finally
            {
                m_boCanQueryBag = false;// 扔物品时,不能刷新包裹
            }
            return result;
        }

        /// <summary>
        /// 召唤英雄
        /// </summary>
        public unsafe void ClientRecallHero()
        {
            if (m_boWaitHeroDate || this.m_boDeath || this.m_boGhost) // 死亡不能再召唤英雄
            {
                return;
            }
            // 不能召唤英雄
            if (!m_boCallHero)
            {
                return;
            }
            if (m_MyHero != null)
            {
                if (m_MyHero.m_boDeath || m_MyHero.m_boGhost)
                {
                    m_MyHero = null;
                }
            }
            m_boHeroLogOut = false;// 英雄退出
            if (m_MyHero != null)
            {
                this.SendUpdateMsg(this, Grobal2.RM_RECALLHERO, 0, m_MyHero.m_ActorsId, 0, 0, "");
                return;
            }
            if (n_HeroSave != 1)
            {
                if ((!m_boHasHero || !m_boHasHeroTwo) && (m_sHeroCharName == ""))
                {
                    this.SysMsg(GameMsgDef.g_sNotHero, TMsgColor.c_Red, TMsgType.t_Hint); //您还没有创建英雄！！！
                }
                else
                {
                    if ((HUtil32.GetTickCount() - m_nRecallHeroTime) > 900) //限制召唤过快
                    {
                        if ((HUtil32.GetTickCount() - m_nRecallHeroTime) > M2Share.g_Config.nRecallHeroTime)// 召唤英雄间隔
                        {
                            m_nRecallHeroTime = HUtil32.GetTickCount();// 召唤英雄间隔
                            M2Share.FrontEngine.AddToLoadHeroRcdList(m_sHeroCharName, "", this, 0);
                        }
                        else
                        {
                            // 召唤英雄间隔
                            this.SysMsg(string.Format(GameMsgDef.g_sRecallHeroHint, (M2Share.g_Config.nRecallHeroTime - (HUtil32.GetTickCount() - m_nRecallHeroTime)) / 1000), TMsgColor.c_Red, TMsgType.t_Hint);
                        }
                    }
                }
            }
            else
            {
                if (m_sHeroCharName != "")
                {
                    if ((HUtil32.GetTickCount() - m_nRecallHeroTime) > 900)// 限制召唤过快
                    {
                        if ((HUtil32.GetTickCount() - m_nRecallHeroTime) > M2Share.g_Config.nRecallHeroTime)// 召唤英雄间隔
                        {
                            m_nRecallHeroTime = HUtil32.GetTickCount(); // 召唤英雄间隔
                            M2Share.FrontEngine.AddToLoadHeroRcdList(m_sHeroCharName, "", this, 0);
                        }
                        else
                        {
                            // 召唤英雄间隔
                            this.SysMsg(string.Format(GameMsgDef.g_sRecallHeroHint, (M2Share.g_Config.nRecallHeroTime - (HUtil32.GetTickCount() - m_nRecallHeroTime)) / 1000), TMsgColor.c_Red, TMsgType.t_Hint);
                        }
                    }
                }
            }
        }

        public void ClientRecallDeputyHero()
        {
            if (m_boWaitHeroDate || this.m_boDeath || this.m_boGhost)// 死亡不能再召唤英雄
            {
                return;
            }
            if (!m_boCallHero) // 不能召唤英雄
            {
                return;
            }
            if (m_MyHero != null)
            {
                return;
            }
            m_boHeroLogOut = false; // 英雄退出
            if (n_HeroSave != 1)
            {
                if ((!m_boHasHero || !m_boHasHeroTwo) && (m_sDeputyHeroCharName == ""))
                {
                    this.SysMsg(GameMsgDef.g_sNotHero, TMsgColor.c_Red, TMsgType.t_Hint); //您还没有创建英雄！！！
                }
                else
                {
                    if ((HUtil32.GetTickCount() - m_nRecallDeputyHeroTime) > 900)// 限制召唤过快
                    {
                        if ((HUtil32.GetTickCount() - m_nRecallDeputyHeroTime) > M2Share.g_Config.RecallDeputyHeroTime)// 召唤英雄间隔
                        {
                            m_nRecallDeputyHeroTime = HUtil32.GetTickCount();// 召唤英雄间隔
                            M2Share.FrontEngine.AddToLoadHeroRcdList(m_sDeputyHeroCharName, "", this, 4);
                        }
                        else
                        {
                            // 召唤英雄间隔
                            this.SysMsg(string.Format(GameMsgDef.g_sRecallHeroHint, (M2Share.g_Config.RecallDeputyHeroTime -
                                (HUtil32.GetTickCount() - m_nRecallDeputyHeroTime)) / 1000), TMsgColor.c_Red, TMsgType.t_Hint);
                        }

                    }
                }
            }
            else
            {
                if (m_sDeputyHeroCharName != "")
                {
                    if ((HUtil32.GetTickCount() - m_nRecallDeputyHeroTime) > 900)// 限制召唤过快
                    {
                        if ((HUtil32.GetTickCount() - m_nRecallDeputyHeroTime) > M2Share.g_Config.RecallDeputyHeroTime)// 召唤英雄间隔
                        {
                            m_nRecallDeputyHeroTime = HUtil32.GetTickCount();// 召唤英雄间隔
                            M2Share.FrontEngine.AddToLoadHeroRcdList(m_sDeputyHeroCharName, "", this, 4);
                        }
                        else
                        {
                            // 召唤英雄间隔
                            this.SysMsg(string.Format(GameMsgDef.g_sRecallHeroHint, (M2Share.g_Config.RecallDeputyHeroTime - (HUtil32.GetTickCount() - m_nRecallDeputyHeroTime)) / 1000), TMsgColor.c_Red, TMsgType.t_Hint);
                        }
                    }
                }
            }
        }

        /// <summary>
        /// 客户端英雄退出
        /// </summary>
        /// <param name="nCode"></param>
        public void ClientHeroLogOut(byte nCode)
        {
            TFlowerEvent FlowerEvent;
            try
            {
                if (m_boWaitHeroDate || m_boHeroLogOut)
                {
                    return;
                }
                if (m_MyHero != null)
                {
                    if (m_MyHero.m_TargetCret != null) // 英雄攻击目标为英雄时,收回英雄,目标英雄则需要攻击主人
                    {
                        if ((m_MyHero.m_TargetCret.m_btRaceServer == Grobal2.RC_HEROOBJECT))
                        {
                            this.SetTargetCreat(m_MyHero.m_TargetCret);
                            m_MyHero.m_TargetCret.SetLastHiter(this);
                        }
                        else if ((m_MyHero.m_TargetCret.m_btRaceServer == Grobal2.RC_PLAYOBJECT) && (((m_MyHero.m_TargetCret) as TPlayObject).m_MyHero != null))
                        {
                            this.SetTargetCreat(m_MyHero.m_TargetCret);
                            ((m_MyHero.m_TargetCret) as TPlayObject).m_MyHero.SetLastHiter(this);
                        }
                    }
                    m_boHeroLogOut = true;// 英雄退出
                    ((THeroObject)(m_MyHero)).boCallLogOut = true;// 英雄正常退出
                    ((THeroObject)(m_MyHero)).m_boDeath = true;
                    if (((THeroObject)(m_MyHero)).m_btMentHero == 1)
                    {
                        m_nRecallHeroTime = HUtil32.GetTickCount();//召唤主将英雄间隔
                    }
                    else
                    {
                        m_nRecallDeputyHeroTime = HUtil32.GetTickCount(); // 召唤副将英雄间隔
                    }
                    FlowerEvent = new TFlowerEvent(m_MyHero.m_PEnvir, m_MyHero.m_nCurrX, m_MyHero.m_nCurrY, Grobal2.SM_HEROLOGOUT, 2500);// 英雄退出动画显示
                    FlowerEvent.m_dwRunTick = 1;// 加速效果显示
                    M2Share.g_EventManager.AddEvent(FlowerEvent);
                    M2Share.UserEngine.SaveHeroRcd(this);// 保存英雄数据
                    this.SendDelayMsg(m_MyHero, Grobal2.RM_MAKEGHOSTHERO, 0, 0, 0, 0, "", 1000);// 修改为1000
                    this.SendUpdateMsg(m_MyHero, Grobal2.RM_DESTROYHERO, 0, m_MyHero.m_ActorsId, 0, 0, "");// 英雄销毁,左上角图标隐藏
                    if (nCode == 0)
                    {
                        // 神奇的力量散去，你的英雄开始沉睡。
                        this.SysMsg(GameMsgDef.g_sHeroClose, TMsgColor.c_Green, TMsgType.t_Hint);
                    }
                }
            }
            catch
            {
                M2Share.MainOutMessage("[异常] TPlayObject.ClientHeroLogOut");
            }
        }

        /// <summary>
        /// 客户端改变英雄状态
        /// </summary>
        public unsafe void ClientChgHeroStatus()
        {
            if (m_boWaitHeroDate)
            {
                return;
            }
            if (((THeroObject)(m_MyHero)) != null)
            {
                if (((THeroObject)(m_MyHero)).m_boProtectStatus)
                {
                    ((THeroObject)(m_MyHero)).m_boProtectStatus = false; // 守护时,一改变状态,则停止守护
                }
                if (((THeroObject)(m_MyHero)).m_btStatus >= 2)
                {
                    ((THeroObject)(m_MyHero)).m_btStatus = 0;
                }
                else
                {
                    ((THeroObject)(m_MyHero)).m_btStatus++;
                }
                switch (((THeroObject)(m_MyHero)).m_btStatus)
                {
                    case 1:
                        if (((THeroObject)(m_MyHero)).m_TargetCret != null)
                        {
                            ((THeroObject)(m_MyHero)).m_TargetCret = null;
                        }
                        ((THeroObject)(m_MyHero)).SysMsg(GameMsgDef.g_sHeroFollow, TMsgColor.C_HeroHint, TMsgType.t_Hint);
                        break;
                    case 0:
                        ((THeroObject)(m_MyHero)).SysMsg(GameMsgDef.g_sHeroAttack, TMsgColor.C_HeroHint, TMsgType.t_Hint);
                        break;
                    case 2:
                        if (((THeroObject)(m_MyHero)).m_TargetCret != null)
                        {
                            ((THeroObject)(m_MyHero)).m_TargetCret = null;
                        }
                        ((THeroObject)(m_MyHero)).SysMsg(GameMsgDef.g_sHeroRest, TMsgColor.C_HeroHint, TMsgType.t_Hint);
                        break;
                }
            }
        }

        /// <summary>
        /// 英雄守护
        /// </summary>
        public unsafe void ClientHeroProtect(int nX, int nY)
        {
            if (m_boWaitHeroDate)
            {
                return;
            }
            if ((M2Share.g_Config.boNoSafeProtect && this.InSafeZone()) || (this.m_PEnvir.m_boNOHEROPROTECT)) // 增加英雄安全区内不能守护,地图禁止守护
            {
                return;
            }
            if (((THeroObject)(m_MyHero)) != null)
            {
                ((THeroObject)(m_MyHero)).m_boProtectStatus = !((THeroObject)(m_MyHero)).m_boProtectStatus;
                if (((THeroObject)(m_MyHero)).m_boProtectStatus)
                {
                    ((THeroObject)(m_MyHero)).m_boProtectOK = false;
                    ((THeroObject)(m_MyHero)).m_nProtectTargetX = nX;
                    ((THeroObject)(m_MyHero)).m_nProtectTargetY = nY;
                    ((THeroObject)(m_MyHero)).SysMsg(string.Format(GameMsgDef.g_sHeroProtect, nX, nY), TMsgColor.BB_Fuchsia, TMsgType.t_Hint);// '英雄:开始守护(%d/%d)'
                }
                else
                {
                    ((THeroObject)(m_MyHero)).m_boProtectOK = false;
                    ((THeroObject)(m_MyHero)).m_nProtectTargetX = -1;
                    ((THeroObject)(m_MyHero)).m_nProtectTargetY = -1;
                    ((THeroObject)(m_MyHero)).SysMsg(string.Format(GameMsgDef.g_sHeroNotProtect, nX, nY), TMsgColor.BB_Fuchsia, TMsgType.t_Hint); // '英雄:停止守护(%d/%d)'
                }
            }
        }

        /// <summary>
        /// 锁定攻击目标
        /// </summary>
        public void ClientHeroAttack(TBaseObject BaseObject, int nX, int nY)
        {
            if (HUtil32.GetTickCount() - m_TargetTime > 1500) // 锁定目标间隔
            {
                if (m_boWaitHeroDate)
                {
                    return;
                }
                if (((THeroObject)(m_MyHero)) != null)
                {
                    if (this.CretInNearXY(BaseObject, nX, nY) && (!((THeroObject)(m_MyHero)).m_boDeath))
                    {
                        if ((BaseObject != this) && (BaseObject != m_MyHero) && (!BaseObject.m_boDeath)) // 加入,怪死后不能再锁定
                        {
                            if ((BaseObject.m_btRaceServer < Grobal2.RC_NPC) || (BaseObject.m_btRaceServer > Grobal2.RC_PEACENPC))
                            {
                                if ((BaseObject.m_btRaceServer != 110) && (BaseObject.m_btRaceServer != 111))
                                {
                                    if (this.IsProperTarget(BaseObject))
                                    {
                                        m_TargetTime = HUtil32.GetTickCount();// 锁定目标间隔
                                        if (((THeroObject)(m_MyHero)).m_boProtectStatus)  // 自动切换英雄状态
                                        {
                                            ((THeroObject)(m_MyHero)).m_boProtectStatus = false;  // 守护时,锁定则停止守护
                                        }
                                        if ((!this.m_PEnvir.m_boMISSION) && (((THeroObject)(m_MyHero)).m_btStatus != 0))
                                        {
                                            ((THeroObject)(m_MyHero)).m_btStatus = 0;// (英雄)状态：攻击
                                            ((THeroObject)(m_MyHero)).SysMsg(GameMsgDef.g_sHeroAttack, TMsgColor.C_HeroHint, TMsgType.t_Hint);
                                        }
                                        if (M2Share.g_Config.boUnKnowHum && BaseObject.IsUsesZhuLi())
                                        {
                                            this.SysMsg(string.Format("攻击目标:{0}", "神秘人"), TMsgColor.c_Red, TMsgType.t_Hint);  //带上斗笠,不显示人的真正名字
                                        }
                                        else
                                        {
                                            if ((BaseObject.m_btRaceServer == Grobal2.RC_PLAYOBJECT))
                                            {
                                                this.SysMsg(string.Format("攻击目标: {0}", BaseObject.m_sCharName), TMsgColor.c_Red, TMsgType.t_Hint);
                                            }
                                            else if ((BaseObject.m_btRaceServer == Grobal2.RC_HEROOBJECT) && (BaseObject.m_Master != null))
                                            {
                                                this.SysMsg(string.Format("攻击目标: {0} 的英雄:{1}", BaseObject.m_Master.m_sCharName, BaseObject.m_sCharName), TMsgColor.c_Red, TMsgType.t_Hint);
                                            }
                                            else
                                            {
                                                this.SysMsg(string.Format("攻击目标: {0}", M2Share.FilterShowName(BaseObject.m_sCharName)), TMsgColor.c_Red, TMsgType.t_Hint);
                                            }
                                        }
                                        ((THeroObject)(m_MyHero)).m_boTarget = true;
                                        ((THeroObject)(m_MyHero)).SetTargetXY(BaseObject.m_nCurrX, BaseObject.m_nCurrY);
                                        ((THeroObject)(m_MyHero)).SetTargetCreat(BaseObject);
                                        this.SetTargetCreat(BaseObject);
                                        if (BaseObject.IsProperTarget(m_MyHero))
                                        {
                                            BaseObject.SetTargetCreat(m_MyHero);  // 对方也把英雄当成目标
                                        }
                                        if ((((THeroObject)(m_MyHero)).m_btJob == 0))
                                        {
                                            if ((Math.Abs(m_MyHero.m_nCurrX - ((THeroObject)(m_MyHero)).m_nTargetX) > 1) || (Math.Abs(m_MyHero.m_nCurrY - ((THeroObject)(m_MyHero)).m_nTargetY) > 1))
                                            {
                                                ((THeroObject)(m_MyHero)).RunToTargetXY(BaseObject.m_nCurrX, BaseObject.m_nCurrY);// 走向锁定的目标
                                            }
                                        }
                                        else
                                        {
                                            if ((Math.Abs(m_MyHero.m_nCurrX - ((THeroObject)(m_MyHero)).m_nTargetX) > 3) || (Math.Abs(m_MyHero.m_nCurrY - ((THeroObject)(m_MyHero)).m_nTargetY) > 3))
                                            {
                                                ((THeroObject)(m_MyHero)).GetGotoXY(((THeroObject)(m_MyHero)).m_TargetCret, 3);// 道法只走向目标3格范围
                                                ((THeroObject)(m_MyHero)).RunToTargetXY(((THeroObject)(m_MyHero)).m_nTargetX, ((THeroObject)(m_MyHero)).m_nTargetY);
                                            }
                                        }
                                        if ((BaseObject.m_btRaceServer == Grobal2.RC_PLAYOBJECT) || (BaseObject.m_btRaceServer == Grobal2.RC_HEROOBJECT))
                                        {
                                            BaseObject.SetPKFlag(this);// 设置主人灰名  
                                            BaseObject.SetPKFlag(m_MyHero);// 设置英雄灰名
                                        }
                                        if (((THeroObject)(m_MyHero)).m_boDecDragonPoint)
                                        {
                                            ClientHeroUseSpell(); // 减怒气时,直接放合击
                                        }
                                        return;
                                    }
                                }
                            }
                        }
                    }
                    ((THeroObject)(m_MyHero)).m_TargetCret = null;
                    ((THeroObject)(m_MyHero)).m_boTarget = false;
                }
            }
        }

        /// <summary>
        /// 开始合击(去掉英雄守护不能合击)
        /// </summary>
        private void ClientHeroUseSpell()
        {
            TUserMagic TogetherMagic;
            int nSpellPoint;
            try
            {
                if (m_boWaitHeroDate)
                {
                    return;
                }
                if ((!m_MyHero.m_boDeath) && (!m_MyHero.m_boGhost) && (!this.m_boDeath) && (!this.m_boGhost))
                {
                    if ((((THeroObject)(m_MyHero)).m_btStatus != 2) && (m_MyHero.m_PEnvir == this.m_PEnvir) && (Math.Abs(m_MyHero.m_nCurrX - this.m_nCurrX) <= 13)
                        && (Math.Abs(m_MyHero.m_nCurrY - this.m_nCurrY) <= 13) && (((THeroObject)(m_MyHero)).WearFirDragon()))// 戴火龙之心才能放合击
                    {
                        if (((THeroObject)(m_MyHero)).m_boTarget) // 锁定目标
                        {
                            if ((m_MyHero.m_TargetCret != null) && (Math.Abs(m_MyHero.m_TargetCret.m_nCurrX - this.m_nCurrX) <= 13) && (Math.Abs(m_MyHero.m_TargetCret.m_nCurrY - this.m_nCurrY) <= 13))
                            {
                                if ((((THeroObject)(m_MyHero)).m_nFirDragonPoint >= M2Share.g_Config.nMaxFirDragonPoint) || (((THeroObject)(m_MyHero)).m_boDecDragonPoint))// 气槽满
                                {
                                    TogetherMagic = ((THeroObject)(m_MyHero)).FindTogetherMagic();
                                    if (TogetherMagic != null)
                                    {
                                        nSpellPoint = GetSpellPoint(TogetherMagic);
                                        if ((nSpellPoint <= this.m_WAbil.MP) && (nSpellPoint <= m_MyHero.m_WAbil.MP))
                                        {
                                            switch (TogetherMagic.wMagIdx)
                                            {
                                                case 60:// 破魂斩
                                                    if ((m_MyHero.m_TargetCret != null))
                                                    {
                                                        this.SetTargetCreat(m_MyHero.m_TargetCret);
                                                    }
                                                    if (((this.m_wStatusTimeArr[Grobal2.POISON_STONE] != 0) || (((THeroObject)(m_MyHero)).m_wStatusTimeArr[Grobal2.POISON_STONE] != 0)) && (!M2Share.g_Config.ClientConf.boParalyCanSpell))
                                                    {
                                                        // 麻痹不能合击
                                                        ((THeroObject)(m_MyHero)).m_boDecDragonPoint = true;// 开始减怒气
                                                        return;
                                                    }
                                                    // 直线才放破魂斩
                                                    if (!((((Math.Abs(this.m_TargetCret.m_nCurrX - m_MyHero.m_nCurrX) == 2) && (Math.Abs(this.m_TargetCret.m_nCurrY - m_MyHero.m_nCurrY) == 0)) || ((Math.Abs(this.m_TargetCret.m_nCurrX - m_MyHero.m_nCurrX) == 1) && (Math.Abs(this.m_TargetCret.m_nCurrY - m_MyHero.m_nCurrY) == 0)) || ((Math.Abs(this.m_TargetCret.m_nCurrX - m_MyHero.m_nCurrX) == 1) && (Math.Abs(this.m_TargetCret.m_nCurrY - m_MyHero.m_nCurrY) == 1)) || ((Math.Abs(this.m_TargetCret.m_nCurrX - m_MyHero.m_nCurrX) == 2) && (Math.Abs(this.m_TargetCret.m_nCurrY - m_MyHero.m_nCurrY) == 2)) || ((Math.Abs(this.m_TargetCret.m_nCurrX - m_MyHero.m_nCurrX) == 0) && (Math.Abs(this.m_TargetCret.m_nCurrY - m_MyHero.m_nCurrY) == 1)) || ((Math.Abs(this.m_TargetCret.m_nCurrX - m_MyHero.m_nCurrX) == 0) && (Math.Abs(this.m_TargetCret.m_nCurrY - m_MyHero.m_nCurrY) == 2)))))
                                                    {
                                                        ((THeroObject)(m_MyHero)).m_boDecDragonPoint = true;// 开始减怒气
                                                        ((THeroObject)(m_MyHero)).GotoTargetXY(m_MyHero.m_TargetCret.m_nCurrX, m_MyHero.m_TargetCret.m_nCurrY, 1);// 英雄走向目标
                                                        return;
                                                    }
                                                    else if (!((((Math.Abs(this.m_TargetCret.m_nCurrX - this.m_nCurrX) == 2) && (Math.Abs(this.m_TargetCret.m_nCurrY - this.m_nCurrY) == 0)) || ((Math.Abs(this.m_TargetCret.m_nCurrX - this.m_nCurrX) == 1) && (Math.Abs(this.m_TargetCret.m_nCurrY - this.m_nCurrY) == 0)) || ((Math.Abs(this.m_TargetCret.m_nCurrX - this.m_nCurrX) == 1) && (Math.Abs(this.m_TargetCret.m_nCurrY - this.m_nCurrY) == 1)) || ((Math.Abs(this.m_TargetCret.m_nCurrX - this.m_nCurrX) == 2) && (Math.Abs(this.m_TargetCret.m_nCurrY - this.m_nCurrY) == 2)) || ((Math.Abs(this.m_TargetCret.m_nCurrX - this.m_nCurrX) == 0) && (Math.Abs(this.m_TargetCret.m_nCurrY - this.m_nCurrY) == 1)) || ((Math.Abs(this.m_TargetCret.m_nCurrX - this.m_nCurrX) == 0) && (Math.Abs(this.m_TargetCret.m_nCurrY - this.m_nCurrY) == 2)))))
                                                    {
                                                        ((THeroObject)(m_MyHero)).m_boDecDragonPoint = true;// 开始减怒气
                                                        return;
                                                    }
                                                    break;
                                                case 61:
                                                case 62:// 劈星斩,雷霆一击(近攻合击,战要近目标) 
                                                    if ((m_MyHero.m_TargetCret != null))  //英雄锁定后，主人被其它目标打时，合击会打不是锁定的目标
                                                    {
                                                        this.SetTargetCreat(m_MyHero.m_TargetCret);
                                                    }
                                                    if (((this.m_wStatusTimeArr[Grobal2.POISON_STONE] != 0) || (((THeroObject)(m_MyHero)).m_wStatusTimeArr[Grobal2.POISON_STONE] != 0)) && (!M2Share.g_Config.ClientConf.boParalyCanSpell))
                                                    {
                                                        // 麻痹不能合击
                                                        ((THeroObject)(m_MyHero)).m_boDecDragonPoint = true;// 开始减怒气
                                                        return;
                                                    }
                                                    if ((this.m_btJob == 0) && ((Math.Abs(m_MyHero.m_TargetCret.m_nCurrX - this.m_nCurrX) > 2) || (Math.Abs(m_MyHero.m_TargetCret.m_nCurrY - this.m_nCurrY) > 2)))
                                                    {
                                                        ((THeroObject)(m_MyHero)).m_boDecDragonPoint = true;// 开始减怒气
                                                        return;
                                                    }
                                                    else if ((((THeroObject)(m_MyHero)).m_btJob == 0) && ((Math.Abs(m_MyHero.m_TargetCret.m_nCurrX - m_MyHero.m_nCurrX) > 2) || (Math.Abs(m_MyHero.m_TargetCret.m_nCurrY - m_MyHero.m_nCurrY) > 2)))
                                                    {
                                                        ((THeroObject)(m_MyHero)).m_boDecDragonPoint = true;// 开始减怒气
                                                        ((THeroObject)(m_MyHero)).GotoTargetXY(m_MyHero.m_TargetCret.m_nCurrX, m_MyHero.m_TargetCret.m_nCurrY, 1);// 英雄走向目标
                                                        return;
                                                    }
                                                    break;
                                                case 63:
                                                case 64:
                                                case 65:
                                                    if (((this.m_wStatusTimeArr[Grobal2.POISON_STONE] != 0) || (((THeroObject)(m_MyHero)).m_wStatusTimeArr[Grobal2.POISON_STONE] != 0)) && (!M2Share.g_Config.ClientConf.boParalyCanSpell))
                                                    {
                                                        //麻痹不能合击
                                                        ((THeroObject)(m_MyHero)).m_boDecDragonPoint = true;// 开始减怒气
                                                        return;
                                                    }
                                                    break;
                                            }
                                            ((THeroObject)(m_MyHero)).m_boStartUseSpell = true;
                                            ((THeroObject)(m_MyHero)).m_boDecDragonPoint = false;// 停止减怒气
                                            ((THeroObject)(m_MyHero)).m_nFirDragonPoint = 0;// 清空怒气值
                                            ((THeroObject)(m_MyHero)).m_dwStartUseSpellTick = HUtil32.GetTickCount();
                                            ((THeroObject)(m_MyHero)).m_dwHitTick = HUtil32.GetTickCount();//直接进入魔法过程,以加速合击速度
                                            if (((THeroObject)(m_MyHero)).ClientSpellXY(TogetherMagic, m_MyHero.m_TargetCret.m_nCurrX, m_MyHero.m_TargetCret.m_nCurrY, m_MyHero.m_TargetCret))
                                            {
                                                ((THeroObject)(m_MyHero)).m_boStartUseSpell = false;
                                            }
                                        }
                                        else
                                        {
                                            // MP不足时提示
                                            if (nSpellPoint > this.m_WAbil.MP)
                                            {
                                                this.SysMsg("MP不足,不能使用合击技能！！！", TMsgColor.c_Red, TMsgType.t_Hint);
                                            }
                                            if (nSpellPoint > m_MyHero.m_WAbil.MP)
                                            {
                                                this.SysMsg("(英雄) MP不足,不能使用合击技能！！！", TMsgColor.c_Red, TMsgType.t_Hint);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (this.m_TargetCret != null) // 没有锁定目标,则攻击当前目标,
                            {
                                m_MyHero.m_TargetCret = this.m_TargetCret;// 释放合击时,如果英雄目标为空,则默认攻击主人的目标
                            }
                            else if ((m_MyHero.m_TargetCret != null))
                            {
                                this.SetTargetCreat(m_MyHero.m_TargetCret);
                            }
                            if ((m_MyHero.m_TargetCret != null) && (Math.Abs(m_MyHero.m_TargetCret.m_nCurrX - this.m_nCurrX) <= 13) && (Math.Abs(m_MyHero.m_TargetCret.m_nCurrY - this.m_nCurrY) <= 13))
                            {
                                if ((((THeroObject)(m_MyHero)).m_nFirDragonPoint >= M2Share.g_Config.nMaxFirDragonPoint) || (((THeroObject)(m_MyHero)).m_boDecDragonPoint))
                                {
                                    TogetherMagic = ((THeroObject)(m_MyHero)).FindTogetherMagic();
                                    if (TogetherMagic != null)
                                    {
                                        nSpellPoint = GetSpellPoint(TogetherMagic);
                                        if ((nSpellPoint <= this.m_WAbil.MP) && (nSpellPoint <= m_MyHero.m_WAbil.MP))
                                        {
                                            switch (TogetherMagic.wMagIdx)
                                            {
                                                case 60:// 破魂斩
                                                    if (this.m_TargetCret != null)
                                                    {
                                                        m_MyHero.SetTargetCreat(this.m_TargetCret);
                                                    }
                                                    else if ((m_MyHero.m_TargetCret != null))
                                                    {
                                                        this.SetTargetCreat(m_MyHero.m_TargetCret);
                                                    }
                                                    if (((this.m_wStatusTimeArr[Grobal2.POISON_STONE] != 0) ||
                                                        (((THeroObject)(m_MyHero)).m_wStatusTimeArr[Grobal2.POISON_STONE] != 0)) &&
                                                        (!M2Share.g_Config.ClientConf.boParalyCanSpell))//  麻痹不能合击
                                                    {
                                                        ((THeroObject)(m_MyHero)).m_boDecDragonPoint = true;// 开始减怒气
                                                        return;
                                                    }
                                                    //修改，直线才放破魂斩
                                                    if (!((((Math.Abs(this.m_TargetCret.m_nCurrX - m_MyHero.m_nCurrX) == 2) && (Math.Abs(this.m_TargetCret.m_nCurrY - m_MyHero.m_nCurrY) == 0)) || ((Math.Abs(this.m_TargetCret.m_nCurrX - m_MyHero.m_nCurrX) == 1) && (Math.Abs(this.m_TargetCret.m_nCurrY - m_MyHero.m_nCurrY) == 0)) || ((Math.Abs(this.m_TargetCret.m_nCurrX - m_MyHero.m_nCurrX) == 1) && (Math.Abs(this.m_TargetCret.m_nCurrY - m_MyHero.m_nCurrY) == 1)) || ((Math.Abs(this.m_TargetCret.m_nCurrX - m_MyHero.m_nCurrX) == 2) && (Math.Abs(this.m_TargetCret.m_nCurrY - m_MyHero.m_nCurrY) == 2)) || ((Math.Abs(this.m_TargetCret.m_nCurrX - m_MyHero.m_nCurrX) == 0) && (Math.Abs(this.m_TargetCret.m_nCurrY - m_MyHero.m_nCurrY) == 1)) || ((Math.Abs(this.m_TargetCret.m_nCurrX - m_MyHero.m_nCurrX) == 0) && (Math.Abs(this.m_TargetCret.m_nCurrY - m_MyHero.m_nCurrY) == 2)))))
                                                    {
                                                        ((THeroObject)(m_MyHero)).m_boDecDragonPoint = true; // 开始减怒气
                                                        ((THeroObject)(m_MyHero)).GotoTargetXY(m_MyHero.m_TargetCret.m_nCurrX, m_MyHero.m_TargetCret.m_nCurrY, 1);// 英雄走向目标
                                                        return;
                                                    }
                                                    else if (!((((Math.Abs(this.m_TargetCret.m_nCurrX - this.m_nCurrX) == 2) && (Math.Abs(this.m_TargetCret.m_nCurrY - this.m_nCurrY) == 0))
                                                        || ((Math.Abs(this.m_TargetCret.m_nCurrX - this.m_nCurrX) == 1) && (Math.Abs(this.m_TargetCret.m_nCurrY - this.m_nCurrY) == 0))
                                                        || ((Math.Abs(this.m_TargetCret.m_nCurrX - this.m_nCurrX) == 1) && (Math.Abs(this.m_TargetCret.m_nCurrY - this.m_nCurrY) == 1))
                                                        || ((Math.Abs(this.m_TargetCret.m_nCurrX - this.m_nCurrX) == 2) && (Math.Abs(this.m_TargetCret.m_nCurrY - this.m_nCurrY) == 2))
                                                        || ((Math.Abs(this.m_TargetCret.m_nCurrX - this.m_nCurrX) == 0) && (Math.Abs(this.m_TargetCret.m_nCurrY - this.m_nCurrY) == 1))
                                                        || ((Math.Abs(this.m_TargetCret.m_nCurrX - this.m_nCurrX) == 0) && (Math.Abs(this.m_TargetCret.m_nCurrY - this.m_nCurrY) == 2)))))
                                                    {
                                                        ((THeroObject)(m_MyHero)).m_boDecDragonPoint = true;// 开始减怒气
                                                        return;
                                                    }
                                                    break;
                                                case 61:
                                                case 62:// 劈星斩,雷霆一击(近攻合击,战要近目标)
                                                    if (this.m_TargetCret != null)
                                                    {
                                                        m_MyHero.SetTargetCreat(this.m_TargetCret);
                                                    }
                                                    else if ((m_MyHero.m_TargetCret != null))
                                                    {
                                                        this.SetTargetCreat(m_MyHero.m_TargetCret);
                                                    }
                                                    if (((this.m_wStatusTimeArr[Grobal2.POISON_STONE] != 0) ||
                                                        (((THeroObject)(m_MyHero)).m_wStatusTimeArr[Grobal2.POISON_STONE] != 0)) &&
                                                        (!M2Share.g_Config.ClientConf.boParalyCanSpell)) // 麻痹不能合击
                                                    {
                                                        ((THeroObject)(m_MyHero)).m_boDecDragonPoint = true; // 开始减怒气
                                                        return;
                                                    }
                                                    if ((this.m_btJob == 0) && ((Math.Abs(this.m_TargetCret.m_nCurrX - this.m_nCurrX) > 1) || (Math.Abs(this.m_TargetCret.m_nCurrY - this.m_nCurrY) > 1)))
                                                    {
                                                        ((THeroObject)(m_MyHero)).m_boDecDragonPoint = true;//开始减怒气

                                                        return;
                                                    }
                                                    else if ((((THeroObject)(m_MyHero)).m_btJob == 0) && ((Math.Abs(this.m_TargetCret.m_nCurrX - m_MyHero.m_nCurrX) > 2) || (Math.Abs(this.m_TargetCret.m_nCurrY - m_MyHero.m_nCurrY) > 2)))
                                                    {
                                                        ((THeroObject)(m_MyHero)).m_boDecDragonPoint = true;// 开始减怒气
                                                        ((THeroObject)(m_MyHero)).GotoTargetXY(m_MyHero.m_TargetCret.m_nCurrX, m_MyHero.m_TargetCret.m_nCurrY, 1); // 英雄走向目标
                                                        return;
                                                    }
                                                    break;
                                                case 63:
                                                case 64:
                                                case 65:
                                                    if (((this.m_wStatusTimeArr[Grobal2.POISON_STONE] != 0) ||
                                                        (((THeroObject)(m_MyHero)).m_wStatusTimeArr[Grobal2.POISON_STONE] != 0)) &&
                                                        (!M2Share.g_Config.ClientConf.boParalyCanSpell)) // 麻痹不能合击
                                                    {
                                                        ((THeroObject)(m_MyHero)).m_boDecDragonPoint = true; // 开始减怒气
                                                        return;
                                                    }
                                                    break;
                                            }
                                            ((THeroObject)(m_MyHero)).m_boStartUseSpell = true;
                                            ((THeroObject)(m_MyHero)).m_boDecDragonPoint = false;//停止减怒气
                                            ((THeroObject)(m_MyHero)).m_nFirDragonPoint = 0; // 清空怒气值
                                            ((THeroObject)(m_MyHero)).m_dwStartUseSpellTick = HUtil32.GetTickCount();
                                            ((THeroObject)(m_MyHero)).m_dwHitTick = HUtil32.GetTickCount();// 直接进入魔法过程,以加速合击速度
                                            if (((THeroObject)(m_MyHero)).ClientSpellXY(TogetherMagic, m_MyHero.m_TargetCret.m_nCurrX, m_MyHero.m_TargetCret.m_nCurrY, m_MyHero.m_TargetCret))
                                            {
                                                ((THeroObject)(m_MyHero)).m_boStartUseSpell = false;
                                            }
                                        }
                                        else
                                        {
                                            if (nSpellPoint > this.m_WAbil.MP)  // MP不足时提示
                                            {
                                                this.SysMsg("MP值不足,不能使用合击技能！！！", TMsgColor.c_Red, TMsgType.t_Hint);
                                            }
                                            if (nSpellPoint > m_MyHero.m_WAbil.MP)
                                            {
                                                this.SysMsg("(英雄) MP值不足,不能使用合击技能！！！", TMsgColor.c_Red, TMsgType.t_Hint);
                                            }
                                        }
                                    }
                                }
                            }
                            else if ((((THeroObject)(m_MyHero)).m_nFirDragonPoint >= M2Share.g_Config.nMaxFirDragonPoint)) // 怒气值满时,才可以减怒气
                            {
                                ((THeroObject)(m_MyHero)).m_boDecDragonPoint = true; // 没有目标也,开始减怒气
                            }

                        }
                    }
                }
            }
            catch
            {
            }
        }

        /// <summary>
        /// 从装备栏取装备放到包裹里
        /// </summary>
        public void ClientTakeOnItemsFormBag(int nIndex, byte btWhere, int nItemIdx, string sItemName)
        {
            int n14;
            int n18;
            TUserItem UserItem = null;
            TUserItem TakeOffItem;
            TStdItem StdItem;
            TStdItem StdItem20;
            TStdItem StdItem58;
            string sUserItemName;
            StdItem = null;
            n14 = -1;
            n18 = -1;
            if ((m_MyHero == null) || m_boWaitHeroDate)
            {
                goto FailExit;
            }
            switch (nIndex)
            {
                case Grobal2.CM_HEROTAKEONITEMFORMMASTERBAG:
                    if (this.m_ItemList.Count > 0)
                    {
                        for (int i = 0; i < this.m_ItemList.Count; i++)
                        {
                            UserItem = this.m_ItemList[i];
                            if ((UserItem != null) && (UserItem.MakeIndex == nItemIdx))
                            {
                                sUserItemName = "";// 取自定义物品名称
                                if (UserItem.btValue[13] == 1)
                                {
                                    sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                                }
                                if (sUserItemName == "")
                                {
                                    sUserItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                                }
                                StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                if (UserItem.btValue[12] == 1)// 物品发光
                                {
                                    StdItem.Reserved1 = 1;
                                }
                                else
                                {
                                    StdItem.Reserved1 = 0;
                                }
                                if (StdItem != null)
                                {
                                    if (string.Compare(sUserItemName, sItemName, true) == 0)
                                    {
                                        n14 = i;
                                        break;
                                    }
                                }
                            }
                            UserItem = null;
                        }
                        n18 = 0;
                        if ((StdItem != null) && (UserItem != null))
                        {
                            if (M2Share.CheckUserItems(btWhere, StdItem))
                            {
                                StdItem58 = StdItem;
                                M2Share.ItemUnit.GetItemAddValue(UserItem, StdItem58);
                                if (((THeroObject)(m_MyHero)).CheckTakeOnItems(btWhere, StdItem58))
                                {
                                    TakeOffItem = null;
                                    if (btWhere >= 0 && btWhere <= 13)  // 支持斗笠,0..12改0..13
                                    {
                                        if (((THeroObject)(m_MyHero)).m_UseItems[btWhere].wIndex > 0)
                                        {
                                            StdItem20 = M2Share.UserEngine.GetStdItem(((THeroObject)(m_MyHero)).m_UseItems[btWhere].wIndex);
                                            if ((StdItem20 != null) && (new ArrayList(new int[] { 15, 19, 20, 21, 22, 23, 24, 26 }).Contains(StdItem20.StdMode)))
                                            {
                                                if ((!this.m_boUserUnLockDurg) && (((THeroObject)(m_MyHero)).m_UseItems[btWhere].btValue[7] != 0))
                                                {
                                                    // '无法取下物品！！！'
                                                    ((THeroObject)(m_MyHero)).SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint);
                                                    n18 = -4;
                                                    goto FailExit;
                                                }
                                            }
                                            // 因为虎啸装备 是吸血成功的几率所以所不能使用 StdItem.Reserved 判断
                                            // Shape=193 Need-(30)需等级，Stock-为吸血点 NeedLevel-所需等级 Reserved-成功机率
                                            // Shape=193 Need-(31)需攻击，Stock-为吸血点 NeedLevel-所需攻击 Reserved-成功机率
                                            // Shape=193 Need-(32)需魔法，Stock-为吸血点 NeedLevel-所需魔法 Reserved-成功机率
                                            // Shape=193 Need-(33)需道术，Stock-为吸血点 NeedLevel-所需道术 Reserved-成功机率
                                            if (!(StdItem.Shape == 193))
                                            {
                                                if (!this.m_boUserUnLockDurg && ((StdItem20.Reserved & 2) != 0))
                                                {
                                                    // '无法取下物品！！！'
                                                    ((THeroObject)(m_MyHero)).SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint);
                                                    n18 = -4;
                                                    goto FailExit;
                                                }
                                                if ((StdItem20.Reserved & 4) != 0)
                                                {
                                                    // '无法取下物品！！！'
                                                    ((THeroObject)(m_MyHero)).SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint);
                                                    n18 = -4;
                                                    goto FailExit;
                                                }
                                            }
                                            if (M2Share.InDisableTakeOffList(((THeroObject)(m_MyHero)).m_UseItems[btWhere].wIndex))
                                            {
                                                // '无法取下物品！！！'
                                                ((THeroObject)(m_MyHero)).SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint);
                                                goto FailExit;
                                            }
                                            TakeOffItem = ((THeroObject)(m_MyHero)).m_UseItems[btWhere];
                                        }
                                        if ((new ArrayList(new int[] { 15, 19, 20, 21, 22, 23, 24, 26 }).Contains(StdItem.StdMode)) && (UserItem.btValue[8] != 0))
                                        {
                                            UserItem.btValue[8] = 0;
                                        }
                                        ((THeroObject)(m_MyHero)).m_UseItems[btWhere] = UserItem;
                                        this.DelBagItem(n14);
                                        if (TakeOffItem != null)
                                        {
                                            if (this.AddItemToBag(TakeOffItem))
                                            {
                                                SendAddItem(TakeOffItem);
                                            }
                                        }
                                        ((THeroObject)(m_MyHero)).RecalcAbilitys();
                                        m_MyHero.CompareSuitItem(false);//套装
                                        ((THeroObject)(m_MyHero)).SendMsg(m_MyHero, Grobal2.RM_HEROABILITY, 0, 0, 0, 0, "");
                                        ((THeroObject)(m_MyHero)).SendMsg(m_MyHero, Grobal2.RM_HEROSUBABILITY, 0, 0, 0, 0, "");
                                        ((THeroObject)(m_MyHero)).WeightChanged();
                                        ((THeroObject)(m_MyHero)).SendDefMessage(Grobal2.SM_HEROTAKEON_OK, ((THeroObject)(m_MyHero)).GetFeatureToLong(), m_MyHero.GetFeatureEx(), 0, 0, "");
                                        ((THeroObject)(m_MyHero)).FeatureChanged();
                                        n18 = 1;
                                    }
                                }
                                else
                                {
                                    n18 = -1;
                                }
                            }
                            else
                            {
                                n18 = -1;
                            }
                        }
                    }
                    break;
                case Grobal2.CM_TAKEONITEMFORMHEROBAG:
                    if (((THeroObject)(m_MyHero)).m_ItemList.Count > 0)
                    {
                        for (int i = 0; i < ((THeroObject)(m_MyHero)).m_ItemList.Count; i++)
                        {
                            UserItem = (TUserItem)((THeroObject)(m_MyHero)).m_ItemList[i];
                            if ((UserItem != null) && (UserItem.MakeIndex == nItemIdx))
                            {
                                sUserItemName = "";// 取自定义物品名称
                                if (UserItem.btValue[13] == 1)
                                {
                                    sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                                }
                                if (sUserItemName == "")
                                {
                                    sUserItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                                }
                                StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                                if (UserItem.btValue[12] == 1)  // 物品发光
                                {
                                    StdItem.Reserved1 = 1;
                                }
                                else
                                {
                                    StdItem.Reserved1 = 0;
                                }
                                if (StdItem != null)
                                {
                                    if (string.Compare(sUserItemName, sItemName, true) == 0)
                                    {
                                        n14 = i;
                                        break;
                                    }
                                }
                            }
                            UserItem = null;
                        }
                        n18 = 0;
                        if ((StdItem != null) && (UserItem != null))
                        {
                            if (M2Share.CheckUserItems(btWhere, StdItem))
                            {
                                StdItem58 = StdItem;
                                M2Share.ItemUnit.GetItemAddValue(UserItem, StdItem58);
                                if (CheckTakeOnItems(btWhere, StdItem58))
                                {
                                    TakeOffItem = null;
                                    if (btWhere >= 0 && btWhere <= 13)// 支持斗笠,0..12改0..13
                                    {
                                        if (this.m_UseItems[btWhere].wIndex > 0)
                                        {
                                            StdItem20 = M2Share.UserEngine.GetStdItem(this.m_UseItems[btWhere].wIndex);
                                            if ((StdItem20 != null) && (new ArrayList(new int[] { 15, 19, 20, 21, 22, 23, 24, 26 }).Contains(StdItem20.StdMode)))
                                            {
                                                if ((!this.m_boUserUnLockDurg) && (((THeroObject)(m_MyHero)).m_UseItems[btWhere].btValue[7] != 0))
                                                {
                                                    // '无法取下物品！！！'
                                                    this.SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint);
                                                    n18 = -4;
                                                    goto FailExit;
                                                }
                                            }
                                            if (!this.m_boUserUnLockDurg && ((StdItem20.Reserved & 2) != 0))
                                            {
                                                // '无法取下物品！！！'
                                                this.SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint);
                                                n18 = -4;
                                                goto FailExit;
                                            }
                                            if ((StdItem20.Reserved & 4) != 0)
                                            {
                                                // '无法取下物品！！！'
                                                this.SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint);
                                                n18 = -4;
                                                goto FailExit;
                                            }
                                            if (M2Share.InDisableTakeOffList(((THeroObject)(m_MyHero)).m_UseItems[btWhere].wIndex))
                                            {
                                                // '无法取下物品！！！'
                                                this.SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint);
                                                goto FailExit;
                                            }
                                            TakeOffItem = this.m_UseItems[btWhere];
                                        }
                                        if ((new ArrayList(new int[] { 15, 19, 20, 21, 22, 23, 24, 26 }).Contains(StdItem.StdMode)) && (UserItem.btValue[8] != 0))
                                        {
                                            UserItem.btValue[8] = 0;
                                        }
                                        this.m_UseItems[btWhere] = UserItem;
                                        ((THeroObject)(m_MyHero)).DelBagItem(n14);
                                        if (TakeOffItem != null)
                                        {
                                            if (((THeroObject)(m_MyHero)).AddItemToBag(TakeOffItem))
                                            {
                                                ((THeroObject)(m_MyHero)).SendAddItem(TakeOffItem);
                                            }
                                        }
                                        RecalcAbilitys();
                                        this.CompareSuitItem(false);//套装
                                        this.SendMsg(this, Grobal2.RM_ABILITY, 0, 0, 0, 0, "");
                                        this.SendMsg(this, Grobal2.RM_SUBABILITY, 0, 0, 0, 0, "");
                                        SendDefMessage(Grobal2.SM_TAKEON_OK, this.GetFeatureToLong(), this.GetFeatureEx(), 0, 0, "");
                                        this.FeatureChanged();
                                        n18 = 1;
                                    }
                                }
                                else
                                {
                                    n18 = -1;
                                }
                            }
                            else
                            {
                                n18 = -1;
                            }
                        }
                    }
                    break;
            }
        FailExit:
            switch (nIndex)
            {
                case Grobal2.CM_HEROTAKEONITEMFORMMASTERBAG:
                    if (n18 <= 0)
                    {
                        SendDefMessage(Grobal2.SM_TAKEON_FAIL, n18, 0, 0, 0, "");
                    }
                    break;
                case Grobal2.CM_TAKEONITEMFORMHEROBAG:
                    if (n18 <= 0)
                    {
                        SendDefMessage(Grobal2.SM_HEROTAKEON_FAIL, n18, 0, 0, 0, "");
                    }
                    break;
            }
        }

        /// <summary>
        /// 英雄穿上装备
        /// </summary>
        public void ClientHeroTakeOnItems(byte btWhere, int nItemIdx, string sItemName)
        {
            int n14;
            int n18;
            TUserItem UserItem = null;
            TUserItem TakeOffItem;
            TStdItem StdItem;
            TStdItem StdItem20;
            TStdItem StdItem58;
            string sUserItemName = string.Empty;
            TBaseObject Slave;
            StdItem = null;
            n14 = -1;
            n18 = -1;
            if ((m_MyHero == null) || m_boWaitHeroDate)
            {
                goto FailExit;
            }
            if (((THeroObject)(m_MyHero)).m_ItemList.Count > 0)
            {
                for (int i = 0; i < ((THeroObject)(m_MyHero)).m_ItemList.Count; i++)
                {
                    UserItem = (TUserItem)((THeroObject)(m_MyHero)).m_ItemList[i];
                    if ((UserItem != null) && (UserItem.MakeIndex == nItemIdx)) // 取自定义物品名称
                    {
                        sUserItemName = "";
                        if (UserItem.btValue[13] == 1)
                        {
                            sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                        }
                        if (sUserItemName == "")
                        {
                            sUserItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                        }
                        StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                        if (UserItem.btValue[12] == 1)// 物品发光
                        {
                            StdItem.Reserved1 = 1;
                        }
                        else
                        {
                            StdItem.Reserved1 = 0;
                        }
                        if (StdItem != null)
                        {
                            if ((sUserItemName).ToLower().CompareTo((sItemName).ToLower()) == 0)
                            {
                                n14 = i;
                                break;
                            }
                        }
                    }
                    UserItem = null;
                }
            }
            n18 = 0;
            if ((StdItem != null) && (UserItem != null))
            {
                if (this.CheckIsOKItem(UserItem, 0)) // 检查变态物品
                {
                    n18 = -1;
                    goto FailExit;
                }
                if ((btWhere == 13) && (M2Share.g_Config.nIsUseZhuLi == 1)) // 如果没有设置人物可带,则不能带上斗笠
                {
                    n18 = -1;
                    goto FailExit;
                }
                if (this.PlugOfCheckCanItem(8, sUserItemName, false, 0, 0)) // 禁止物品规则(禁止英雄使用)
                {
                    n18 = -1;
                    goto FailExit;
                }
                if (M2Share.CheckUserItems(btWhere, StdItem))
                {
                    StdItem58 = StdItem;
                    M2Share.ItemUnit.GetItemAddValue(UserItem, StdItem58);
                    if (((THeroObject)(m_MyHero)).CheckTakeOnItems(btWhere, StdItem58))
                    {
                        TakeOffItem = null;
                        if (btWhere >= 0 && btWhere <= 13)  // 支持斗笠,0..12改0..13
                        {
                            if (((THeroObject)(m_MyHero)).m_UseItems[btWhere].wIndex > 0)
                            {
                                StdItem20 = M2Share.UserEngine.GetStdItem(((THeroObject)(m_MyHero)).m_UseItems[btWhere].wIndex);
                                if ((StdItem20 != null))
                                {
                                    switch (StdItem20.StdMode)
                                    {
                                        case 15:
                                        case 16:
                                        case 19:
                                        case 26:
                                            if ((!this.m_boUserUnLockDurg) && (((THeroObject)(m_MyHero)).m_UseItems[btWhere].btValue[7] != 0))
                                            {
                                                ((THeroObject)(m_MyHero)).SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint);// '无法取下物品！！！'
                                                n18 = -4;
                                                goto FailExit;
                                            }
                                            break;
                                    }
                                }
                                if (!this.m_boUserUnLockDurg && ((StdItem20.Reserved & 2) != 0))
                                {
                                    ((THeroObject)(m_MyHero)).SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint);  // '无法取下物品！！！'
                                    n18 = -4;
                                    goto FailExit;
                                }
                                if ((StdItem20.Reserved & 4) != 0)
                                {
                                    ((THeroObject)(m_MyHero)).SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint);  // '无法取下物品！！！'
                                    n18 = -4;
                                    goto FailExit;
                                }
                                if (M2Share.InDisableTakeOffList(((THeroObject)(m_MyHero)).m_UseItems[btWhere].wIndex))
                                {
                                    ((THeroObject)(m_MyHero)).SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint);   // '无法取下物品！！！'
                                    goto FailExit;
                                }
                                TakeOffItem = ((THeroObject)(m_MyHero)).m_UseItems[btWhere];
                            }
                            if (UserItem.btValue[8] != 0)
                            {
                                switch (StdItem.StdMode)
                                {
                                    case 15:
                                    case 16:
                                    case 19:
                                    case 26:
                                        UserItem.btValue[8] = 0;
                                        break;
                                }
                            }
                            ((THeroObject)(m_MyHero)).m_UseItems[btWhere] = UserItem;
                            ((THeroObject)(m_MyHero)).DelBagItem(n14);
                            if (TakeOffItem != null)
                            {
                                if (((THeroObject)(m_MyHero)).AddItemToBag(TakeOffItem))
                                {
                                    ((THeroObject)(m_MyHero)).SendAddItem(TakeOffItem);
                                }
                            }
                            if (btWhere == Grobal2.U_BUJUK)
                            {
                                if (!((THeroObject)(m_MyHero)).WearFirDragon())   // 没火龙之心,不显示怒气值 
                                {
                                    ((THeroObject)(m_MyHero)).SendMsg(m_MyHero, Grobal2.RM_FIRDRAGONPOINT, 0, 0, 0, 0, "");// 发送英雄怒气值 
                                }
                            }
                            ((THeroObject)(m_MyHero)).RecalcAbilitys();
                            m_MyHero.CompareSuitItem(true);// 套装与身上装备对比
                            ((THeroObject)(m_MyHero)).SendMsg(m_MyHero, Grobal2.RM_HEROABILITY, 0, 0, 0, 0, "");
                            ((THeroObject)(m_MyHero)).SendMsg(m_MyHero, Grobal2.RM_HEROSUBABILITY, 0, 0, 0, 0, "");
                            ((THeroObject)(m_MyHero)).SendDefMessage(Grobal2.SM_HEROTAKEON_OK, ((THeroObject)(m_MyHero)).GetFeatureToLong(), m_MyHero.GetFeatureEx(), 0, 0, "");
                            ((THeroObject)(m_MyHero)).FeatureChanged();
                            if (StdItem.StdMode == 16)// 如果是斗笠则更新名字
                            {
                                ((THeroObject)(m_MyHero)).RefShowName();// 宝宝也更新名字
                                if (m_MyHero.m_SlaveList.Count > 0)
                                {
                                    for (int i = 0; i < m_MyHero.m_SlaveList.Count; i++)
                                    {
                                        Slave = m_MyHero.m_SlaveList[i];
                                        if ((Slave != null) && (!Slave.m_boDeath))
                                        {
                                            Slave.RefShowName();
                                        }
                                    }
                                }
                            }
                            n18 = 1;
                        }
                    }
                    else
                    {
                        n18 = -2;
                    }
                }
                else
                {
                    n18 = -1;
                }
            }
        FailExit:
            if (n18 <= 0)
            {
                SendDefMessage(Grobal2.SM_HEROTAKEON_FAIL, n18, 0, 0, 0, "");
            }
        }

        /// <summary>
        /// 英雄脱下装备
        /// </summary>
        /// <param name="btWhere"></param>
        /// <param name="nItemIdx"></param>
        /// <param name="sItemName"></param>
        public unsafe void ClientHeroTakeOffItems(byte btWhere, int nItemIdx, string sItemName)
        {
            int n10;
            TStdItem StdItem;
            TUserItem UserItem;
            string sUserItemName;
            TBaseObject Slave;
            n10 = 0;
            if ((m_MyHero == null) || m_boWaitHeroDate)
            {
                goto FailExit;
            }
            if (!m_boDealing && (btWhere < 14)) // 支持斗笠
            {
                if (((THeroObject)(m_MyHero)).m_UseItems[btWhere].wIndex > 0)
                {
                    if (((THeroObject)(m_MyHero)).m_UseItems[btWhere].MakeIndex == nItemIdx)
                    {
                        StdItem = M2Share.UserEngine.GetStdItem(((THeroObject)(m_MyHero)).m_UseItems[btWhere].wIndex);
                        if ((StdItem != null) && (new ArrayList(new int[] { 15, 16, 19, 20, 21, 22, 23, 24, 26 }).Contains(StdItem.StdMode)))
                        {
                            if ((!this.m_boUserUnLockDurg) && (((THeroObject)(m_MyHero)).m_UseItems[btWhere].btValue[7] != 0))
                            {
                                ((THeroObject)(m_MyHero)).SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint);//无法取下物品！！！
                                n10 = -4;
                                goto FailExit;
                            }
                        }
                        if (!this.m_boUserUnLockDurg && ((StdItem.Reserved & 2) != 0))
                        {
                            ((THeroObject)(m_MyHero)).SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint); // '无法取下物品！！！'
                            n10 = -4;
                            goto FailExit;
                        }
                        if ((StdItem.Reserved & 4) != 0)
                        {
                            ((THeroObject)(m_MyHero)).SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint);  // '无法取下物品！！！'
                            n10 = -4;
                            goto FailExit;
                        }
                        if (M2Share.InDisableTakeOffList(((THeroObject)(m_MyHero)).m_UseItems[btWhere].wIndex))
                        {
                            ((THeroObject)(m_MyHero)).SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint);// '无法取下物品！！！'
                            goto FailExit;
                        }
                        // 取自定义物品名称
                        sUserItemName = "";
                        if (((THeroObject)(m_MyHero)).m_UseItems[btWhere].btValue[13] == 1)
                        {
                            sUserItemName = M2Share.ItemUnit.GetCustomItemName(((THeroObject)(m_MyHero)).m_UseItems[btWhere].MakeIndex, ((THeroObject)(m_MyHero)).m_UseItems[btWhere].wIndex);
                        }
                        if (sUserItemName == "")
                        {
                            sUserItemName = M2Share.UserEngine.GetStdItemName(((THeroObject)(m_MyHero)).m_UseItems[btWhere].wIndex);
                        }
                        if ((sUserItemName).ToLower().CompareTo((sItemName).ToLower()) == 0)
                        {
                            UserItem = new TUserItem();
                            for (int i = 0; i < 22; i++)
                            {
                                UserItem.btValue[i] = 0;
                            }
                            UserItem = ((THeroObject)(m_MyHero)).m_UseItems[btWhere];
                            if (((THeroObject)(m_MyHero)).AddItemToBag(UserItem))
                            {
                                ((THeroObject)(m_MyHero)).m_UseItems[btWhere].wIndex = 0;
                                ((THeroObject)(m_MyHero)).SendAddItem(UserItem);
                                ((THeroObject)(m_MyHero)).RecalcAbilitys();
                                m_MyHero.CompareSuitItem(false);  // 套装与身上装备对比
                                ((THeroObject)(m_MyHero)).SendMsg(m_MyHero, Grobal2.RM_HEROABILITY, 0, 0, 0, 0, "");
                                ((THeroObject)(m_MyHero)).SendMsg(m_MyHero, Grobal2.RM_HEROSUBABILITY, 0, 0, 0, 0, "");
                                ((THeroObject)(m_MyHero)).SendDefMessage(Grobal2.SM_HEROTAKEOFF_OK, ((THeroObject)(m_MyHero)).GetFeatureToLong(), m_MyHero.GetFeatureEx(), 0, 0, "");
                                ((THeroObject)(m_MyHero)).FeatureChanged();
                                if (StdItem.StdMode == 16)
                                {
                                    ((THeroObject)(m_MyHero)).RefShowName();// 如果是斗笠则更新名字
                                    if (m_MyHero.m_SlaveList.Count > 0) //宝宝也更新名字
                                    {
                                        for (int i = 0; i < m_MyHero.m_SlaveList.Count; i++)
                                        {
                                            Slave = ((m_MyHero.m_SlaveList[i]) as TBaseObject);
                                            if ((Slave != null) && (!Slave.m_boDeath))
                                            {
                                                Slave.RefShowName();
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                               UserItem=null;
                                n10 = -3;
                            }
                        }
                    }
                }
                else
                {
                    n10 = -2;
                }
            }
            else
            {
                n10 = -1;
            }
        FailExit:
            if (n10 <= 0)
            {
                SendDefMessage(Grobal2.SM_HEROTAKEOFF_FAIL, n10, 0, 0, 0, "");
            }
        }

        public unsafe void ClientHeroTakeOffItemsToBag(int nIndex, byte btWhere, int nItemIdx, string sItemName)
        {
            int n10;
            TStdItem StdItem;
            TUserItem UserItem;
            string sUserItemName;
            n10 = 0;
            if ((m_MyHero == null) || m_boWaitHeroDate)
            {
                goto FailExit;
            }
            switch (nIndex)
            {
                case Grobal2.CM_TAKEOFFITEMHEROBAG:// 装备脱下到英雄包裹
                    if (!m_boDealing && (btWhere < 13))
                    {
                        if (this.m_UseItems[btWhere].wIndex > 0)
                        {
                            if (this.m_UseItems[btWhere].MakeIndex == nItemIdx)
                            {
                                StdItem = M2Share.UserEngine.GetStdItem(this.m_UseItems[btWhere].wIndex);
                                if ((StdItem != null) && (new ArrayList(new int[] { 15, 16, 19, 20, 21, 22, 23, 24, 26 }).Contains(StdItem.StdMode)))
                                {
                                    if ((!this.m_boUserUnLockDurg) && (((THeroObject)(m_MyHero)).m_UseItems[btWhere].btValue[7] != 0))
                                    {
                                        // '无法取下物品！！！'
                                        this.SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint);
                                        n10 = -4;
                                        goto FailExit;
                                    }
                                }
                                if (!this.m_boUserUnLockDurg && ((StdItem.Reserved & 2) != 0))
                                {
                                    // '无法取下物品！！！'
                                    this.SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint);
                                    n10 = -4;
                                    goto FailExit;
                                }
                                if ((StdItem.Reserved & 4) != 0)
                                {
                                    // '无法取下物品！！！'
                                    this.SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint);
                                    n10 = -4;
                                    goto FailExit;
                                }
                                if (M2Share.InDisableTakeOffList(this.m_UseItems[btWhere].wIndex))
                                {
                                    // '无法取下物品！！！'
                                    this.SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint);
                                    goto FailExit;
                                }
                                // 取自定义物品名称
                                sUserItemName = "";
                                if (this.m_UseItems[btWhere].btValue[13] == 1)
                                {
                                    sUserItemName = M2Share.ItemUnit.GetCustomItemName(this.m_UseItems[btWhere].MakeIndex, this.m_UseItems[btWhere].wIndex);
                                }
                                if (sUserItemName == "")
                                {
                                    sUserItemName = M2Share.UserEngine.GetStdItemName(this.m_UseItems[btWhere].wIndex);
                                }
                                if ((sUserItemName).ToLower().CompareTo((sItemName).ToLower()) == 0)
                                {
                                    UserItem = new TUserItem();
                                    for (int i = 0; i < 22; i++)
                                    {
                                        UserItem.btValue[i] = 0;
                                    }
                                    UserItem = this.m_UseItems[btWhere];
                                    if (((THeroObject)(m_MyHero)).AddItemToBag(UserItem))
                                    {
                                        ((THeroObject)(m_MyHero)).SendAddItem(UserItem);
                                        this.m_UseItems[btWhere].wIndex = 0;
                                        RecalcAbilitys();
                                        this.CompareSuitItem(false);//套装
                                        this.SendMsg(this, Grobal2.RM_ABILITY, 0, 0, 0, 0, "");
                                        this.SendMsg(this, Grobal2.RM_SUBABILITY, 0, 0, 0, 0, "");
                                        SendDefMessage(Grobal2.SM_TAKEOFFTOHEROBAG_OK, this.GetFeatureToLong(), this.GetFeatureEx(), 0, 0, "");
                                        this.FeatureChanged();
                                        n10 = 1;
                                    }
                                    else
                                    {
                                       UserItem=null;
                                        n10 = -3;
                                    }
                                }
                            }
                        }
                        else
                        {
                            n10 = -2;
                        }
                    }
                    else
                    {
                        n10 = -1;
                    }
                    break;
                case Grobal2.CM_TAKEOFFITEMTOMASTERBAG:// 装备脱下到主人包裹
                    if (!m_boDealing && (btWhere < 13))
                    {
                        if (((THeroObject)(m_MyHero)).m_UseItems[btWhere].wIndex > 0)
                        {
                            if (((THeroObject)(m_MyHero)).m_UseItems[btWhere].MakeIndex == nItemIdx)
                            {
                                StdItem = M2Share.UserEngine.GetStdItem(((THeroObject)(m_MyHero)).m_UseItems[btWhere].wIndex);
                                if ((StdItem != null) && (new ArrayList(new int[] { 15, 16, 19, 20, 21, 22, 23, 24, 26 }).Contains(StdItem.StdMode)))
                                {
                                    if ((!this.m_boUserUnLockDurg) && (((THeroObject)(m_MyHero)).m_UseItems[btWhere].btValue[7] != 0))
                                    {
                                        ((THeroObject)(m_MyHero)).SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint);// '无法取下物品！！！'
                                        n10 = -4;
                                        goto FailExit;
                                    }
                                }
                                if (!this.m_boUserUnLockDurg && ((StdItem.Reserved & 2) != 0))
                                {
                                    // '无法取下物品！！！'
                                    ((THeroObject)(m_MyHero)).SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint);
                                    n10 = -4;
                                    goto FailExit;
                                }
                                if ((StdItem.Reserved & 4) != 0)
                                {
                                    // '无法取下物品！！！'
                                    ((THeroObject)(m_MyHero)).SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint);
                                    n10 = -4;
                                    goto FailExit;
                                }
                                if (M2Share.InDisableTakeOffList(((THeroObject)(m_MyHero)).m_UseItems[btWhere].wIndex))
                                {
                                    // '无法取下物品！！！'
                                    ((THeroObject)(m_MyHero)).SysMsg(GameMsgDef.g_sCanotTakeOffItem, TMsgColor.c_Red, TMsgType.t_Hint);
                                    goto FailExit;
                                }
                                // 取自定义物品名称
                                sUserItemName = "";

                                if (((THeroObject)(m_MyHero)).m_UseItems[btWhere].btValue[13] == 1)
                                {
                                    sUserItemName = M2Share.ItemUnit.GetCustomItemName(((THeroObject)(m_MyHero)).m_UseItems[btWhere].MakeIndex, ((THeroObject)(m_MyHero)).m_UseItems[btWhere].wIndex);
                                }
                                if (sUserItemName == "")
                                {
                                    sUserItemName = M2Share.UserEngine.GetStdItemName(((THeroObject)(m_MyHero)).m_UseItems[btWhere].wIndex);
                                }
                                if ((sUserItemName).ToLower().CompareTo((sItemName).ToLower()) == 0)
                                {
                                    UserItem = new TUserItem();
                                    for (int i = 0; i < 22; i++)
                                    {
                                        UserItem.btValue[i] = 0;
                                    }
                                    UserItem = ((THeroObject)(m_MyHero)).m_UseItems[btWhere];
                                    if (this.AddItemToBag(UserItem))
                                    {
                                        SendAddItem(UserItem);
                                        this.WeightChanged();
                                        ((THeroObject)(m_MyHero)).m_UseItems[btWhere].wIndex = 0;
                                        ((THeroObject)(m_MyHero)).RecalcAbilitys();
                                        m_MyHero.CompareSuitItem(false);// 套装
                                        ((THeroObject)(m_MyHero)).WeightChanged();
                                        ((THeroObject)(m_MyHero)).SendMsg(m_MyHero, Grobal2.RM_HEROABILITY, 0, 0, 0, 0, "");
                                        ((THeroObject)(m_MyHero)).SendMsg(m_MyHero, Grobal2.RM_HEROSUBABILITY, 0, 0, 0, 0, "");
                                        ((THeroObject)(m_MyHero)).SendDefMessage(Grobal2.SM_TAKEOFFTOMASTERBAG_OK, ((THeroObject)(m_MyHero)).GetFeatureToLong(), m_MyHero.GetFeatureEx(), 0, 0, "");
                                        ((THeroObject)(m_MyHero)).FeatureChanged();
                                        n10 = 1;
                                    }
                                    else
                                    {
                                       UserItem=null;
                                        n10 = -3;
                                    }
                                }
                            }
                        }
                        else
                        {
                            n10 = -2;
                        }
                    }
                    else
                    {
                        n10 = -1;
                    }
                    break;
            }
        FailExit:
            switch (nIndex)
            {
                case Grobal2.CM_TAKEOFFITEMHEROBAG:// 装备脱下到英雄包裹
                    if (n10 <= 0)
                    {
                        SendDefMessage(Grobal2.SM_TAKEOFFTOHEROBAG_FAIL, n10, 0, 0, 0, "");
                    }
                    break;
                case Grobal2.CM_TAKEOFFITEMTOMASTERBAG:// 装备脱下到主人包裹
                    if (n10 <= 0)
                    {
                        SendDefMessage(Grobal2.SM_TAKEOFFTOMASTERBAG_FAIL, n10, 0, 0, 0, "");
                    }
                    break;
            }
        }

        /// <summary>
        /// 包裹到包裹
        /// </summary>
        /// <param name="nIndex"></param>
        /// <param name="nItemIdx"></param>
        /// <param name="sItemName"></param>
        public unsafe void ClientBagToBag(int nIndex, int nItemIdx, string sItemName)
        {
            
            int n10;
            int wIndex;
            int MakeIndex;
            TStdItem StdItem;
            TUserItem UserItem;
            string sUserItemName;
            n10 = 0;
            if ((m_MyHero == null) || m_boWaitHeroDate || m_boHeroLogOut)
            {
                goto FailExit;
            }
            switch (nIndex)
            {
                case Grobal2.CM_SENDITEMTOHEROBAG:// 主人包裹到英雄包裹
                    for (var i = this.m_ItemList.Count - 1; i >= 0; i--)
                    {
                        if (this.m_ItemList.Count <= 0)
                        {
                            break;
                        }
                        UserItem = this.m_ItemList[i];
                        if (UserItem.MakeIndex == nItemIdx)
                        {
                            if (this.PlugOfCheckCanItem(8, sItemName, false, 0, 0))// 禁止物品规则,禁止英雄使用(管理插件功能)
                            {
                                goto FailExit;
                            }
                            StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                            if (StdItem == null)
                            {
                                goto FailExit;
                            }
                            // 取自定义物品名称
                            sUserItemName = "";
                            if (UserItem.btValue[13] == 1)
                            {
                                sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                            }
                            if (sUserItemName == "")
                            {
                                sUserItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                            }
                            if (((sUserItemName).ToLower().CompareTo((sItemName).ToLower()) == 0) && (((m_sHeroCharName).ToLower().CompareTo((m_MyHero.m_sCharName).ToLower()) == 0) || ((m_sDeputyHeroCharName).ToLower().CompareTo((m_MyHero.m_sCharName).ToLower()) == 0)))
                            {
                                ((THeroObject)(m_MyHero)).ClearCopyItem(UserItem.wIndex, UserItem.MakeIndex);// 先清理英雄包裹复制品
                                if (m_boHeroLogOut)// 英雄退出,则失败
                                {

                                    goto FailExit;
                                }
                                if (((THeroObject)(m_MyHero)).AddItemToBag(UserItem))
                                {
                                    this.m_ItemList.RemoveAt(i);
                                    ((THeroObject)(m_MyHero)).SendAddItem(UserItem);
                                    IsItem_51(1);// 发送聚灵珠的经验
                                    ((THeroObject)(m_MyHero)).SendDefMessage(Grobal2.SM_SENDITEMTOHEROBAG_OK, 0, 0, 0, 0, "");
                                    this.WeightChanged();// 负重改变
                                    ((THeroObject)(m_MyHero)).WeightChanged();// 负重改变
                                    n10 = 1;
                                }
                                else
                                {
                                    n10 = -3;
                                }
                                break;
                            }
                        }
                    }
                    break;
                case Grobal2.CM_SENDITEMTOMASTERBAG:// 英雄包裹到主人包裹
                    for (var i = m_MyHero.m_ItemList.Count - 1; i >= 0; i--)
                    {
                        if (m_MyHero.m_ItemList.Count <= 0)
                        {
                            break;
                        }
                        UserItem = (TUserItem)m_MyHero.m_ItemList[i];
                        if (UserItem.MakeIndex == nItemIdx)
                        {
                            StdItem = M2Share.UserEngine.GetStdItem(UserItem.wIndex);
                            if (StdItem == null)
                            {
                                goto FailExit;
                            }
                            // 取自定义物品名称
                            sUserItemName = "";
                            if (UserItem.btValue[13] == 1)
                            {
                                sUserItemName = M2Share.ItemUnit.GetCustomItemName(UserItem.MakeIndex, UserItem.wIndex);
                            }
                            if (sUserItemName == "")
                            {
                                sUserItemName = M2Share.UserEngine.GetStdItemName(UserItem.wIndex);
                            }
                            if (((sUserItemName).ToLower().CompareTo((sItemName).ToLower()) == 0) && (((m_sHeroCharName).ToLower().CompareTo((m_MyHero.m_sCharName).ToLower()) == 0) || ((m_sDeputyHeroCharName).ToLower().CompareTo((m_MyHero.m_sCharName).ToLower()) == 0)))
                            {
                                ClearCopyItem(0, UserItem.wIndex, UserItem.MakeIndex);
                                if (m_boHeroLogOut) // 英雄退出,则失败
                                {
                                    goto FailExit;
                                }
                                if (this.AddItemToBag(UserItem))
                                {
                                    m_MyHero.m_ItemList.RemoveAt(i);
                                    wIndex = UserItem.wIndex;
                                    MakeIndex = UserItem.MakeIndex;
                                    ((THeroObject)(m_MyHero)).ClearCopyItem(wIndex, MakeIndex);
                                    SendAddItem(UserItem);
                                    IsItem_51(1);// 发送聚灵珠的经验
                                    SendDefMessage(Grobal2.SM_SENDITEMTOMASTERBAG_OK, 0, 0, 0, 0, "");
                                    this.WeightChanged();// 负重改变
                                    ((THeroObject)(m_MyHero)).WeightChanged();// 负重改变
                                    n10 = 1;
                                }
                                else
                                {
                                    n10 = -3;
                                }
                                break;
                            }
                        }
                    }
                    break;
            }
        FailExit:
            switch (nIndex)
            {
                case Grobal2.CM_SENDITEMTOHEROBAG:// 主人包裹到英雄包裹
                    if (n10 <= 0)
                    {
                        SendDefMessage(Grobal2.SM_SENDITEMTOHEROBAG_FAIL, n10, 0, 0, 0, "");
                    }
                    break;
                case Grobal2.CM_SENDITEMTOMASTERBAG:// 英雄包裹到主人包裹
                    if (n10 <= 0)
                    {
                        SendDefMessage(Grobal2.SM_SENDITEMTOMASTERBAG_FAIL, n10, 0, 0, 0, "");
                    }
                    break;
            }
        }

        /// <summary>
        /// 英雄使用物品
        /// </summary>
        /// <param name="nItemIdx"></param>
        /// <param name="sItemName"></param>
        private void ClientHeroUseItems(int nItemIdx, string sItemName)
        {
            if (m_boWaitHeroDate)
            {
                return;
            }
            if (((THeroObject)(m_MyHero)) != null)
            {
                ((THeroObject)(m_MyHero)).ClientHeroUseItems(nItemIdx, sItemName);
            }
        }
    }
}
